2

The project in Android Studio has instrumentation tests in the androidTest folder in a single class and used to work ok. I made a change to the project and now the test class fails to find its dependencies (specified in the app Gradle build file) unless I change androidTestCompile to compile (which obviously I cannot). The source listing is covered in red errors re @RunWith, AndroidJUnit4, @Test, InstrumentationRegistry, etc.

I cannot configure the instrumentation configuration in the IDE as the field to specify the class says the class does not exist (it does).

The ultimate cause of this was changes made to move the tests (JVM and Android) from an incorrect package to the same package as the application - that did not break the JVM tests, but has broken the Android tests. The test files are in the right folders, and the correct package name (matching) is specified in the class files. It looks that the project has "forgotten" that the androidTest folder is where it is, but where is that configured?

I've tried rebuilding the project, and restarting the IDE after invalidating its caches. Neither helped.

Anyone have any ideas how I might fix this? I suspect I may need to delete all the IDE files and reimport from Gradle, but it would be nice if there was an easier way.

Ollie C
  • 28,313
  • 34
  • 134
  • 217
  • I made numerous attempts to fix this with no success. But then several days later without me doing anything deliberate to fix it, the problem resolved itself. – Ollie C Apr 27 '17 at 10:01
  • 1
    Does this help? https://stackoverflow.com/questions/30292783/androidtest-folder-doesnt-show-on-androidstudio – ZiglioUK Feb 27 '18 at 14:57

0 Answers0