Search code examples
javaandroidtestinggradleandroid-espresso

How Can use Espresso 2 (for tests) with extends Application (android.app.Application)?


I have gradle android-project. My project work, and my espresso-tests work too.

But If I adding my implementation android.app.Application (extends Application and <application android:name=".AppInstance" ... in AndroidManifest) - throw - tests not found, when I start their, by connectedAndroidTest.

How Can I use android.app.Application (extends Application) with library Espresso 2?

I found goode example with espresso 2 and extends Application (http://engineering.circle.com/instrumentation-testing-with-dagger-mockito-and-espresso/), but tests in this example do not work :(


Solution

  • This helped me - https://github.com/bryanstern/dagger-instrumentation-example/issues/1

    I had to add some code to build.gradle:

    debugCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
    debugCompile 'com.google.dexmaker:dexmaker:1.0'
    debugCompile 'org.mockito:mockito-core:1.10.17'
    
    debugCompile ('com.android.support.test.espresso:espresso-core:2.0') {
        exclude group: 'javax.inject'
    }
    debugCompile 'com.android.support.test:testing-support-lib:0.1'