Package dagger.hilt.android.testing
Annotation Interface UninstallModules
An annotation used to uninstall modules that have previously been installed with
InstallIn
.
This feature should only be used in tests. It is useful for replacing production bindings with fake bindings. The basic idea is to allow users to uninstall the module that provided the production binding so that a fake binding can be provided by the test.
Example:
@HiltAndroidTest
@UninstallModules({
ProdFooModule.class,
})
public class MyTest {
@Module
@InstallIn(SingletonComponent.class)
interface FakeFooModule {
@Binds Foo bindFoo(FakeFoo fakeFoo);
}
}
-
Optional Element Summary
-
Element Details
-
value
Class<?>[] valueReturns the list of classes to uninstall.These classes must be annotated with both
Module
andInstallIn
.Note:A module that is included as part of another module's
Module.includes()
cannot be truly uninstalled until the including module is also uninstalled.- Default:
- {}
-