@UseModules

@UseModules annotation can be used to inherit bindings from an already existing module. @UseModules an array of module classes and can be applied to a test class or a test methods. The only restriction is that the modules imported must not extends JukitoModule.

Here's an exemple that you can find under the Jukito test sources:

@RunWith(JukitoRunner.class)@UseModules({AbcModule.class,DefModule.class})publicclassUseModulesTestextendsUseModulesTestBase{interfaceAbc{}interfaceDef{}interfaceGhj{}interfaceKlm{}staticclassAbcImplimplementsAbc{}staticclassDefImplimplementsDef{}staticclassAbcImpl2implementsAbc{}staticclassDefImpl2implementsDef{}staticclassKlmImplimplementsKlm{}@Test@UseModules(XyzModule.class)publicvoidtestInjectionUsingMethodModules(Abcabc,Defdef){assertTrue(abcinstanceofAbcImpl2);assertTrue(definstanceofDefImpl2);}@TestpublicvoidtestInjectionWithExternalModules(Abcabc,Defdef,Klmklm){assertTrue(abcinstanceofAbcImpl);assertTrue(definstanceofDefImpl);assertTrue(klminstanceofKlmImpl);}@TestpublicvoidtestAutoMockingForMissingBindings(Ghjghj){assertNotNull(ghj);assertTrue(Mockito.mockingDetails(ghj).isMock());}}classXyzModuleextendsAbstractModule{@Overrideprotectedvoidconfigure(){bind(Abc.class).to(UseModulesTest.AbcImpl2.class);bind(Def.class).to(UseModulesTest.DefImpl2.class);}}@UseModules({DefModule.class,KlmModule.class})abstractclassUseModulesTestBase{// KlmModule should get installed// DefModule should be ignored because subClass has it}classAbcModuleextendsAbstractModule{@Overrideprotectedvoidconfigure(){bind(Abc.class).to(AbcImpl.class);}}classDefModuleextendsAbstractModule{@Overrideprotectedvoidconfigure(){bind(Def.class).to(DefImpl.class);}}classKlmModuleextendsAbstractModule{@Overrideprotectedvoidconfigure(){bind(Klm.class).to(KlmImpl.class);}}