[openstack-dev] [Openstack][Horizon] Sharable Angular mock

Thai Q Tran tqtran at us.ibm.com
Mon Jul 20 17:37:52 UTC 2015


Love the idea, great explanation! I see value in this going forward.
Definitely interested.



From:	"Chen, Shaoquan" <sean.chen2 at hp.com>
To:	"OpenStack Development Mailing List (not for usage questions)"
            <openstack-dev at lists.openstack.org>
Date:	07/19/2015 05:34 PM
Subject:	[openstack-dev] [Openstack][Horizon] Sharable Angular mock



Currently random mock objects are created inside of spec files to make
writing unit tests easier. This approach works but has some drawback:

  *   mocks are not sharable between specs.
  *   mocks are usually too simple.
  *   mocks may not be consistent between spec files.
  *   mocks are not tested theme self.
  *   hard to maintain and manage.

In order to make it easy for developers to write high quality unit tests
and e2e test, we want a set of high-quality mock objects. To make its easy
to maintain:

  *   mocks should reside in ``.mock.js`` files and be loaded only in test
runner page
  *   mocks should be loaded after production code files, before spec code
files.
  *   mocks should be sharable between specs.
  *   mocks are not belong to specs, they should have a 1:1 relationship
with the object it try to mock.
  *   mocks should be at a level as low as possible, maybe where JavaScript
cannot reach directly.
  *   mocks must be tested theme self.
  *   mocks should be easy to find, use and manage.

I drafted a simple BP at
https://blueprints.launchpad.net/horizon/+spec/horizon-angular-mocks to
summaries the issue existing in Horizon IMO and how I could see to fix
them. I also setup two patches to prove the concept at:

  *   https://review.openstack.org/#/c/202817/
  *   https://review.openstack.org/#/c/202830/

This mock is for the window object and another could be
OpenStackHtttpBackend which mimic all the behaviors of Horizon Web
services. As you can see, the window mock object can be easily applied to a
bug Tyr fixed recently so that the spec code do not need to create an
inline mock object. Because those shared mock are independent from specs,
they can be more neutral and can have much more features than a over
simplified mock for a specific test.

Please let me know if this interested you.

Thanks,
Sean

__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150720/95df7a27/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150720/95df7a27/attachment.gif>


More information about the OpenStack-dev mailing list