We need to do it so that we can pass in mock modules @Singleton @Component(modules = { TestAndroidModule.class, CommonModule.class }) public interface TestApplicationComponent extends ApplicationComponent { void inject(MainActivity mainActivity); }
So that we can wire it all together public class MockApp extends MyApplication { private TestApplicationComponent component; @Override public void onCreate() { super.onCreate(); component = DaggerTestApplicationComponent.builder() .testAndroidModule(new TestAndroidModule()) … .build(); } @Override public ApplicationComponent component() { return component; } }