Chad Schultz
Chad Schultz

Reputation: 7860

JUnit/Espresso: "empty test suite"

Far too often in Android Studio I run into this problem: I can run the entire suite of UI Tests just fine, but cannot run a single file or a single test case. When I try, I will get an error such as:

Process finished with exit code 1
Class not found: "com.example.MyTest"Empty test suite.

Upvotes: 2

Views: 874

Answers (1)

Chad Schultz
Chad Schultz

Reputation: 7860

It's a hassle, but I have found a solution.

Go to Edit Configurations...

enter image description here

Add a new test configuration manually. Make sure to select Android Instrumented Tests

enter image description here

Type in a name for this configuration - probably just the name of the class.

enter image description here

Select the appropriate module from the drop-down list. Then select the "Class" option (assuming you want to run one file's worth of tests at a time)

enter image description here

Click the ... button and search for the specific class you want. Then hit OK to exit the Run Configuration screen.

Make sure your new configuration is selected and that it is showing the icon with an Android head. This means it is an Android Instrumented Test, which is necessary for Espresso. Otherwise it will try (and fail) to run it as a regular JUnit test.

Done! Now you should be able to run your tests.

Upvotes: 1

Related Questions