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



From:   "Chen, Shaoquan" <sean.ch...@hp.com>
To:     "OpenStack Development Mailing List (not for usage questions)"
            <openstack-dev@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-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

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

Reply via email to