I am following the guide here: https://github.com/ecgreb/dagger-2-testing-demo
I have the following setup in my app/src/main (the injection and @Provides code omitte
You need to add following to your build.gradle file for instrumentation test:
androidTestApt 'com.google.dagger:dagger-compiler:'
or for JUnit test:
testApt 'com.google.dagger:dagger-compiler:'
This is required to generate Dagger code for your test components.
EDIT:
If you are using jack tool chain then add following
for android test:
androidTestAnnotationProcessor 'com.google.dagger:dagger-compiler:'
for JUnit tests:
testAnnotationProcessor 'com.google.dagger:dagger-compiler:'
EDIT:
In case you are using kotlin-kapt for Kotlin code use following:
kaptAndroidTest 'com.google.dagger:dagger-compiler:'
or for JUnit test:
kaptTest 'com.google.dagger:dagger-compiler:'
Check this link for more info.