File this under “I’m writing this so when I Google for it in 6 months, it pops up”.
I recently set up an existing Android project with Espresso 2.0 and immediately stared running into this error when I ran the tests:
Running tests Test running started Test running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException' Empty test suite.
I spent some time last night fighting this error and then I figured out the solution this morning.
The problem is that I’m using Dagger in this project and Espresso 2.0 also uses Dagger (see Espresso Dependencies). The core problem is that the ‘javax.inject’ dependency was borking the test run.
How to to Fix
Change this
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0')
to this:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0') { exclude group: 'javax.inject' }
Problem solved.