简体   繁体   中英

Android Studio 3.2 empty test suite

I have created a new project in 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

没有发现任何测试

I am attempting to run the tests by right clicking on the group and clicking Run 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. 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. 在此输入图像描述

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.

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 . If you are using Windows replace ./gradlew with 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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