简体   繁体   English

Android Studio 3.2空测试套件

[英]Android Studio 3.2 empty test suite

I have created a new project in Android Studio 3.2. 我在Android Studio 3.2中创建了一个新项目。 Without making any changes I am not able to run all the unit tests in the group. 在不进行任何更改的情况下,我无法在组中运行所有单元测试。 I receive and error saying No tests were found 我收到并且错误地说No tests were found

没有发现任何测试

I am attempting to run the tests by right clicking on the group and clicking Run Tests . 我试图通过右键单击该组并单击Run TestsRun Tests

I can run the unit tests if I open up the file and click on the run button next to the class declaration. 如果我打开文件并单击类声明旁边的运行按钮,我可以运行单元测试。 I can also run the unit tests if I open the project in Android Studio 3.1.4. 如果我在Android Studio 3.1.4中打开项目,我也可以运行单元测试。 I can right click on the group and run all the unit tests with no error. 我可以右键单击该组并运行所有单元测试,没有错误。

在此输入图像描述

看看这个错误报告,我认为它应该在3.2.1中修复: https//issuetracker.google.com/issues/115708445#comment12

After spending an entire day trying resolve this while writing some unit tests I found one workaround that works for my project. 花了一整天的时间尝试解决这个问题,同时编写了一些单元测试,我找到了一个适用于我的项目的解决方法。

Basically what my workaround is to add Build to the Before launch options. 基本上我的解决方法是将Build添加到Before launch选项。 在此输入图像描述

After adding this option I'll occasionally get the No tests found error message but simply rerunning the test worked every time after adding that setting. 添加此选项后,我偶尔会收到No tests found错误消息,但只是在添加该设置后每次重新运行测试。

I'm not sure if it will help with everyone's problem but it seems to have mitigated the issue with my project. 我不确定它是否会对每个人的问题有所帮助,但似乎已经缓解了我的项目问题。 Hopefully this works for someone else as well. 希望这也适用于其他人。

The workaround until the bug is fixed is running tests in terminal, just type: ./gradlew test or ./gradlew testDebugUnitTest . 修复错误之前的解决方法是在终端中运行测试,只需输入: ./gradlew test./gradlew testDebugUnitTest If you are using Windows replace ./gradlew with gradlew.bat . 如果您使用Windows,请将./gradlew替换为gradlew.bat You can also download Android Studio 3.3 Canary from here https://developer.android.com/studio/preview/ – there aren't problems with running tests via this version. 您也可以从https://developer.android.com/studio/preview/下载Android Studio 3.3 Canary - 通过此版本运行测试没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM