Package dagger.hilt.android.testing
Annotation Type BindElementsIntoSet
-
@Retention(CLASS) @Target(FIELD) public @interface BindElementsIntoSet
An annotation that can be used on a test field to contribute the value into theSingletonComponent
as anElementsIntoSet
for the given type. Example usage:
Here, bindedSet will be accessible to the entire application for your test. This is functionally equivalent to installing the following module in your test:public class FooTest{ ... @BindElementsIntoSet Set
bindedSet = ImmutableSet.of("bar", "baz"); ... }
Also see@Module @InstallIn interface MyModule { @Provides @ElementsIntoSet Set
bindSet() { return ImmutableSet.of("bar", "baz"); } } BindValueIntoSet
, where you can gather individual elements into one set and bind it to the application.