By http://blog.sqisland.com/2015/04/dagger-2-espresso-2-mockito.html
Github code https://github.com/chiuki/android-test-demo
Override dagger Module by androidTesting. Demo App in folder android-test-demo-master
- override TestRunner in app/build.gradle
defaultConfig {
applicationId 'com.sqisland.android.test_demo'
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName '1.0.0'
testInstrumentationRunner 'com.sqisland.android.test_demo.MockTestRunner'
}
In MockTestRunner we call MockDemoApplication.java
-
app/buld.gradle dependency androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.11" for build components and modules in TestActivity for DaggerMainActivityTest_TestComponent.builder().build(); in MockDemoApplication.java
-
edit Configuration MainActivityTest.java to change TestRunner to MockTestRunner
By http://blog.sqisland.com/2015/04/dagger-2-espresso-2-mockito.html
Github code https://github.com/chiuki/android-test-demo
Override dagger Module by androidTesting. Demo App in folder android-test-demo-master
defaultConfig {
applicationId 'com.sqisland.android.test_demo'
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName '1.0.0'
}
In MockTestRunner we call MockDemoApplication.java
app/buld.gradle dependency androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.11" for build components and modules in TestActivity for DaggerMainActivityTest_TestComponent.builder().build(); in MockDemoApplication.java
edit Configuration MainActivityTest.java to change TestRunner to MockTestRunner