dave08
02/19/2018, 12:05 PMoleksiyp
02/19/2018, 12:07 PMneil.armstrong
02/19/2018, 12:08 PMTestAppModule
which provides your mocks should work just the sameneil.armstrong
02/19/2018, 12:10 PM@Module
class TestAppModule(private val application: Application) {
@Singleton
@Provides
fun provideMockNavigationRouter(): NavigationRouter = mock()
...
}
val component = DaggerEspressoTestComponent
.builder()
.testAppModule(TestAppModule(application))
.build()
Application.dependencies = component
dave08
02/19/2018, 12:14 PMpublic var dependencies
in your Application's companion object
? So the real dependencies get loaded and then you overwrite them w/ the test deps?dave08
02/19/2018, 12:15 PMdave08
02/19/2018, 12:16 PMneil.armstrong
02/19/2018, 12:16 PMEspressoTestComponent
which extends the ApplicationComponent
so that we can override what gets injected
@Singleton
@Component(modules = [TestAppModule::class])
interface EspressoTestComponent : ApplicationComponent {
@Singleton
@Component(modules = [AppModule::class])
interface ApplicationComponent {
neil.armstrong
02/19/2018, 12:16 PMneil.armstrong
02/19/2018, 12:17 PMdave08
02/19/2018, 12:18 PMneil.armstrong
02/19/2018, 12:19 PMdave08
02/19/2018, 12:19 PMoleksiyp
02/19/2018, 1:30 PM