Derwrecked
Derwrecked

Reputation: 811

"No tests were found" during Android UI Testing

If I want to run a single test sometimes by right clicking on the test then selecting run, the test results would show "No tests were found" with an error related to "Exception in thread "main" java.lang.NoClassDefFoundError".

I found this to only happen some times, why is this occurring?

Upvotes: 2

Views: 2626

Answers (2)

Aldinjo
Aldinjo

Reputation: 432

For me, the solution was a gradle sync (File/Sync Project with Gradle Files) and a rebuild of the project

Upvotes: 1

Derwrecked
Derwrecked

Reputation: 811

I found the issue to be that when using the method of right clicking on a test then running it, Android Studio sometimes runs the Android UI Test as a unit test instead of a UI test. After looking into some comments this can occur if you have multiple nested directories in your androidTest directory.

To get around this you will have to go to the 'Edit Configurations.." in the current configuration dropdown: enter image description here

Create a new 'Android Instrumented Test' and you should set the module to app, and the class to the path name of your ui test class. You can even choose the 'Method' option and provide a method within the class provided in the path.

enter image description here

Hope this helps. This was a very annoying bug in Android Studio that was taking time off of my testing.

Cheers!

Upvotes: 1

Related Questions