In the end it was because I didn't have a default constructor in my instrumentation class!
Unit/Instrumentation tests Android Gradle. Instrumentation tests won't run
-
30-06-2023 - |
Question
I have Tests set up in an Android project in Android Studio. I have a Unit test class with tests and an Instrumentation test class with tests. When I run gradlew connectedAndroidTest the unit tests run fine but the instrumentation tests are not run.
Here is my project structure
root - app - src - androidTest - java - packagename - UnitTest class - InstrumentationTest class
The unit test class extends TestCase. The instrumentation test class extends ActivityInstrumentationTestCase2
An example test in the instrumentation test class is
public void testJSONReturnsString() {
String json = JSON.getJSonFeed(getActivity().getApplicationContext(), "http://foo.bar");
assertNotNull(json);
}
In my build.gradle I have testInstrumentationRunner "android.test.InstrumentationTestRunner"
in the defaultConfig section
Does anyone know why the Instrumentation test class wouldn't run?
Solution