On Mon, Jul 5, 2010 at 10:21, Vincent Massol <[email protected]> wrote: > Hi, > > Some time ago I had added the AbstractMockingComponentTestCase class in > shared-test. I've refactored it a bit over the week end to make it even > easier to use. > > The idea is to use a @MockingRequirement annotation in the test case class to > get a component instance with all its @Requirement fields injected with mocks. > > This makes it easier to test than using the older AbstractComponentTestCase > since you don't need to setup component mocks manually. > > Here's an example usage: > > public class MacroContentTableBlockDataSourceTest extends > AbstractMockingComponentTestCase > { > �...@mockingrequirement > private MacroContentTableBlockDataSource source; > ... > > Another example: > > public class DefaultMacroManagerTest extends AbstractMockingComponentTestCase > { > // Mock all required components except for some for which we want to use > the real implementations since they make > // the test easier to write (no need to mock them). > �...@mockingrequirement(exceptions = { ComponentManager.class, > MacroIdFactory.class }) > private DefaultMacroManager macroManager; > > As you can see in this second example, it's also possible to exclude some > @Requirement from being mocked if need be. > > I'd like that we agree to use this new test class from now on instead of > AbstractComponentTestCase (unless there are cases where it's not usable but > please discuss those use cases with me since maybe there are solutions to > improve AbstractMockingComponentTestCase). > > Here's my +1
Sounds good, +1 > > Thanks > -Vincent > > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs > -- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

