[Engine-devel] The easy way to mock Config in your unit tests

Allon Mureinik amureini at redhat.com
Mon May 14 09:03:01 UTC 2012


Here's the outcome of the thread below:
http://ovirt.org/wiki/MockConfigRule

Enjoy!

Many thanks to the patches' reviewers.

----- Original Message -----
> From: "Laszlo Hornyak" <lhornyak at redhat.com>
> To: "engine-devel" <engine-devel at ovirt.org>
> Sent: Monday, May 7, 2012 2:23:10 PM
> Subject: Re: [Engine-devel] The correct way to create test dependencies	between
> 
> +1
> I like the idea, I think this would really improve our unit tests.
> 
> ----- Original Message -----
> > From: "Allon Mureinik" <amureini at redhat.com>
> > To: "engine-devel" <engine-devel at ovirt.org>
> > Sent: Sunday, May 6, 2012 2:46:03 PM
> > Subject: [Engine-devel] The correct way to create test dependencies
> > between
> > 
> > Hi guys,
> > 
> > I've recently come up with (what I believe is) an elegant way to
> > mock
> > the Config object using JUnit @Rules and Mockito  (The gritty
> > details can be found at http://gerrit.ovirt.org/4155).
> > 
> > This presented me with another issue:
> > On the one hand, the code depends on junit and mockito jars, which
> > are not available in the main scope, only in the test scope.
> > On the other hand, in vanilla Maven there is no dependency between
> > tests of different projects, so placing this class in util's test
> > would make it inaccessible to bll tests.
> > 
> > The solution Maven suggests for these kind of issues is creating a
> > test jar
> > (http://maven.apache.org/guides/mini/guide-attached-tests.html): In
> > addition to the regular jar the module produces, you'll get another
> > -test jar, which other modules can depend on using the
> > <type>test-jar</type>, which could of course be put in
> > <scope>test</scope>.
> > 
> > Before pushing forward with this approach, I'd like to know if
> > anyone
> > has a principle objection to it.
> > 
> > 
> > Thanks,
> > Allon
> > _______________________________________________
> > Engine-devel mailing list
> > Engine-devel at ovirt.org
> > http://lists.ovirt.org/mailman/listinfo/engine-devel
> > 
> _______________________________________________
> Engine-devel mailing list
> Engine-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/engine-devel
> 



More information about the Engine-devel mailing list