Annotation Type TestInstallIn


  • @Retention(CLASS)
    @Target(TYPE)
    public @interface TestInstallIn
    An annotation that replaces one or more InstallIn modules with the annotated module in tests.

    The annotated class must also be annotated with Module.

    Example:

    
       // Replaces FooModule with FakeFooModule, and installs it into the same component as FooModule.
       @Module
       @TestInstallIn(components = SingletonComponent.class, replaces = FooModule.class)
       public final class FakeFooModule {
         @Provides
         static Foo provideFoo() {
           return new FakeFoo();
         }
       }
     
    See Also:
    Hilt Modules
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.Class<?>[] components
      Returns the component(s) into which the annotated module will be installed.
      java.lang.Class<?>[] replaces
      Returns the InstallIn module(s) that the annotated class will replace in tests.
    • Element Detail

      • components

        java.lang.Class<?>[] components
        Returns the component(s) into which the annotated module will be installed.
      • replaces

        java.lang.Class<?>[] replaces
        Returns the InstallIn module(s) that the annotated class will replace in tests.