On Jul 9, 2012, at 9:38 AM, Thomas Mortagne wrote:
On Mon, Jul 9, 2012 at 9:32 AM, Vincent Massol <[email protected]> wrote:
Hi devs,
Over the weekend I've brought one change to xwiki-commons-test.
Now by default when you write a unit test that extends AbstractMockingComponentTestCase there will be no component registered against the component manager except those mocked automatically by the @MockingRequirement annotation.
This has 2 advantages: * This is the spirit of AbstractMockingComponentTestCase since they're supposed to mock all dependencies and define their behaviors * It makes the tests up to 10 times faster
If you really need to register some components, use the {@link ComponentList} annotation and if you really really need to register all components (it takes time) then use {@link AllComponents}.
Do we really need to support loading all components in AbstractMockingComponentTestCase since there is AbstractComponentTestCase for that ?
I have migrated all tests using AbstractMockingComponentTestCase and if you check the commits you'll see I've used @AllComponents in several places. I started adding the component implementations one by one but when I reached 10 or so I stopped doing it, removed the list and instead used @AllComponents. What this means is that the unit test is not correctly written and it needs to be modified. So yes @AllComponent should not be used in general and once we have fixed existing tests we can remove it. We could revisit existing tests using @AllComponents and instead use @ComponentList even if there are 20 entries in it and then remove @AllComponent. I didn't have the courage to do this yesterday since I already spent a substantial time on this. Also note that AbstractMockingComponentTestCase and AbstractComponentTestCase are for different needs: * AbstractMockingComponentTestCase is for writing unit tests * AbstractComponentTestCase is for writing integration tests Thanks -Vincent