cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mice Xia" <>
Subject Re: guide to writing unit tests
Date Wed, 08 Aug 2012 15:23:18 GMT

Hi Chiradeep,

I'm about to write a unit test for CS-15609, as you suggested in the review thread.
However it seems a little bit heavy weight if follow the guide you posted:
1) About IoC, I had to inject all dependent DAOs/Managers for the class under test, even if
I want to test one method which needs only one or two DAOs. Does it fit the convention to
bypass the IoC and directly create dependency I needed? suppose I dont need it get configured
or started automatically.
2) About mocks/stubs, I know mockito is removed from tree, but without a mock utility, it
is lengthy to create stub method. Any chance that we can bring it back or find a replacement?

following is an example snip with mocks and without injector:

StorageManager storageMgr = mock(StorageManager.class);
doReturn(true).when(storageMgr).storagePoolHasEnoughSpace(Arrays.asList(volA), sp1);
_firstFitPlanner._storageMgr = storageMgr;


2012/7/27 Chiradeep Vittal <>

    This has always been there. Just surfacing it.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message