[openstack-dev] [nova] Do we have some guidelines for mock, stub, mox when writing unit test?

John Garbutt john at johngarbutt.com
Thu Jan 2 14:58:55 UTC 2014

On 21 December 2013 13:24, Matt Riedemann <mriedem at linux.vnet.ibm.com> wrote:
> On 12/19/2013 8:51 AM, John Garbutt wrote:
>> On 4 December 2013 17:10, Russell Bryant <rbryant at redhat.com> wrote:
>>> I think option 3 makes the most sense here (pending anyone saying we
>>> should run away screaming from mox3 for some reason).  It's actually
>>> what I had been assuming since this thread a while back.
>>> This means that we don't need to *require* that tests get converted if
>>> you're changing one.  It just gets you bonus imaginary internet points.
>>> Requiring mock for new tests seems fine.  We can grant exceptions in
>>> specific cases if necessary.  In general, we should be using mock for
>>> new tests.
>> I have lost track a bit here.
>> The above seems like a sane approach. Do we all agree on that now?
>> Can we add the above text into here:
>> https://wiki.openstack.org/wiki/ReviewChecklist#Nova_Review_Checklist
>> John
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> Yeah, at some point I wanted to cleanup the various testing guides but until
> then I like the idea of just putting something simple into the nova review
> checklist. Basically use mock for new tests, mox can be used in exceptional
> cases. What I've considered exceptional so far includes changes that will be
> backported to a stable release where mock isn't being used and cases where
> you basically have to bend over backwards to work new mock tests into an
> existing test class that has lots of existing setUp with mox. However, even
> in the latter case you can usually use mock after resetting the mox setup
> via self.mox.ResetAll() in the new test case(s).

The wiki looks good to me, thank you!


More information about the OpenStack-dev mailing list