[openstack-dev] [nova] Do we have some guidelines for mock, stub, mox when writing unit test?
Matt Riedemann
mriedem at linux.vnet.ibm.com
Sat Dec 21 13:24:19 UTC 2013
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).
--
Thanks,
Matt Riedemann
More information about the OpenStack-dev
mailing list