找不到类:在Android Studio中运行单元测试时,测试套件为空 [英] Class not found: Empty test suite when running unit tests in Android Studio
问题描述
我为我的Android应用提供了一个测试套件,并且所有单元测试都运行良好.但是,每当我对一个单元测试类(例如,ModelUnitTests
)进行单个更改时,尝试再次运行该类时,都会收到此消息
I have a test suite for my Android app, and all unit tests run fine. However, whenever I make a single change in one of my unit test classes (for example, ModelUnitTests
), when trying to run that class again, I get this message
Process finished with exit code 1
Class not found: "xxx.xxxxxx.xxx.ModelUnitTests"Empty test suite.
如果我进行了gradle清理,然后再次运行类测试,它可以正常运行(但是需要4分钟才能完成...),但是新的更改将再次破坏它.
If I do a gradle clean and then run the class tests again, it runs fine (but it takes 4 minutes to do...), but then a new change will break it again.
有关如何解决此问题的任何建议?我不确定应该发布哪个测试配置.我正在使用单元测试工件,而我的测试位于
module/src/test/package
文件夹
Any advice on how to fix this? I'm not exactly sure which test configuration should I post. I'm using the Unit Tests artifact and my tests are located on the
module/src/test/package
folder
推荐答案
我遇到了类似的问题,这是因为我首先创建了具有相同类名的单元测试.当我创建仪器化的单元测试时,我得到了错误.
I had a similar problem and it was because I first created an Unit Test with the same class name. When I created the Instrumented Unit Test I got the error.
为解决此问题,我转到运行图标左侧的编辑配置".然后在单元测试下面,是冲突" 类,我删除了.单击应用/确定".然后,我右键单击类名,单击run和voilà,它会起作用.
To solve it, I went to Edit Configurations, on the left of the run icon. Then below Unit Test, it was the 'conflicting' class, which I deleted. Click on Apply/Ok. Then I right click on the class name, click on run and voilà, it works.
这篇关于找不到类:在Android Studio中运行单元测试时,测试套件为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!