JUnit/Espresso: “empty test suite”

允我心安 提交于 2019-12-28 04:34:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!