JUnit/Espresso:“空测试套件" [英] JUnit/Espresso: "empty test suite"

查看:97
本文介绍了JUnit/Espresso:“空测试套件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio中经常遇到这种问题:我可以很好地运行整个UI测试套件,但不能运行单个文件或单个测试用例.当我尝试时,会出现诸如以下的错误:

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.

推荐答案

这很麻烦,但是我找到了解决方法.

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

转到Edit Configurations...

手动添加新的测试配置.确保选择Android Instrumented Tests

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)

单击...按钮并搜索所需的特定班级.然后按OK退出运行配置"屏幕.

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

确保已选择新配置,并且该配置显示的图标带有Android头部.这意味着这是Espresso必需的Android Instrumented测试.否则,它将尝试(失败)作为常规JUnit测试运行.

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.

这篇关于JUnit/Espresso:“空测试套件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆