I have a test suite within my Android studio that has the following dir structure:
-MainProject
-src
--com
--tests
--java.xx.xxx.xx.test
Within my AndroidManifest, I have the following:
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="tests.java.xxx.xxx.xxx.test" />
When I run my tests from the command line using: ./gradlew connectedInstrumentTest
, I simply get:
Tests on Nexus 5 - 4.4.2 failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
When I run the tests from inside Android Studio I get:
Running tests
Test running startedTest running failed: Unable to find instrumentation info for: ComponentInfo{tests.xxx.xxx.xxx.xxx.test/android.test.InstrumentationTestRunner}
Empty test suite.
I also have the testPackageName specified in my defaultConfig in the build.gradle file. Am running Android Studio 0.4.6 on Ubuntu 12.0.4.
Any ideas?
I had the same problem and could not find anything on the net. The answer was pretty simple: You have to edit the RunConfiguration of your test so that it is not a Android Test but a JUnit test.
So basically I did the following:
That's it.
I also get error like this and I added the following line in build.gradle file as shown in https://google.github.io/android-testing-support-library/docs/espresso/setup/index.html and it's working. I hope it will also help you :-)
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With