Annotation Interface UninstallModules


@Target(TYPE) public @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

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Returns the list of classes to uninstall.
  • Element Details

    • value

      Class<?>[] value
      Returns the list of classes to uninstall.

      These classes must be annotated with both Module and InstallIn.

      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:
      {}