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

查看:41
本文介绍了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.

转到编辑配置...

手动添加新的测试配置.确保选择 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 头像的图标.这意味着它是一个 Android Instrumented 测试,这是 Espresso 所必需的.否则,它将尝试(但失败)将其作为常规 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天全站免登陆