Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of custom Application class containing values for mocking UI-Test-components
class TestAppApplication : Application() {
// initialize mock ApiService
var mockApiService = MockApiService
/**
* onCreate
*
*/
override fun onCreate() {
super.onCreate()
// init dependency injection
val appComponent = DaggerAppComponent.builder()
.apiModule(object : ApiModule() {
override fun provideApiService(): ApiService {
return mockApiService.service
}
})
.build()
// set AppComponent
Injector.INSTANCE.set(appComponent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment