问题
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.
回答1:
It's a hassle, but I have found a solution.
Go to Edit Configurations...
Add a new test configuration manually. Make sure to select Android Instrumented Tests
Type in a name for this configuration - probably just the name of the class.
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)
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.
来源:https://stackoverflow.com/questions/53715512/junit-espresso-empty-test-suite