Skip to content

Instantly share code, notes, and snippets.

@flipper83
Created September 15, 2017 13:45
Show Gist options
  • Save flipper83/12c75e770dd45b6003ebcdaf173ae02e to your computer and use it in GitHub Desktop.
Save flipper83/12c75e770dd45b6003ebcdaf173ae02e to your computer and use it in GitHub Desktop.
injection
//MainActivity.java
public class MainActivity extends BaseActivity implements SuperHeroesPresenter.View {
@Inject SuperHeroesPresenter presenter;
/* ... */
}
//MainModule.java
@Module public class MainModule {
@Provides @Singleton public SuperHeroesRepository provideSuperHeroesRepository() {
return new SuperHeroesRepository();
}
}
//MainActivityTest
@RunWith(AndroidJUnit4.class) @LargeTest public class MainActivityTest {
private static final int ANY_NUMBER_OF_SUPER_HEROES = 100;
@Rule public DaggerMockRule<MainComponent> daggerRule =
new DaggerMockRule<>(
/* ... */
);
@Mock SuperHeroesRepository repository;
/* ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment