Hello! I'm facing this error whenever I want to cr...
# dagger
j
Hello! I'm facing this error whenever I want to create UI tests with Espresso using Dagger
java.lang.RuntimeException: android.app.Application does not implement dagger.android.HasAndroidInjector
Any idea, why? It only happens with UI tests, the app runs and everything is injected correctly.
j
Do you use some kind of Test Application class?
w
You probably need to create custom test runner (
AndroidJUnitRunner
) and override
fun newApplication
method to call something like
super.newApplication(cl, TestApplication::class.java.name, context)
And set
android.defaultConfig.testInstrumentationRunner = <your custom runner>
That’s just a quick fyi that it’s usually done, I don’t know if instrumentation tests should use your default class from manifest by default or not
j
@Jovan No I do not, shall I?
@wasyl Do you have a sample where I can guide to do it? I get you but not 100%