“未找到测试".在Android UI测试期间 [英] "No tests were found" during Android UI Testing

查看:114
本文介绍了“未找到测试".在Android UI测试期间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有时我想通过右键单击测试然后选择运行来运行单个测试,则测试结果将显示未找到测试",并显示与线程主"中的异常" java.lang.NoClassDefFoundError相关的错误.

If I want to run a single test sometimes by right clicking on the test then selecting run, the test results would show "No tests were found" with an error related to "Exception in thread "main" java.lang.NoClassDefFoundError".

我发现这种情况只会发生几次,为什么会这样呢?

I found this to only happen some times, why is this occurring?

推荐答案

我发现问题是,当使用右键单击测试然后运行它的方法时,Android Studio有时会运行 将Android UI测试作为单元测试而不是UI测试.在查看了一些注释后,如果您在androidTest目录中有多个嵌套目录,则可能会发生这种情况.

I found the issue to be that when using the method of right clicking on a test then running it, Android Studio sometimes runs the Android UI Test as a unit test instead of a UI test. After looking into some comments this can occur if you have multiple nested directories in your androidTest directory.

要解决此问题,您将必须转到当前配置下拉菜单中的编辑配置..":

To get around this you will have to go to the 'Edit Configurations.." in the current configuration dropdown:

创建一个新的"Android Instrumented Test",您应该将模块设置为app,并将该类设置为ui测试类的路径名.您甚至可以选择方法"选项,并在路径中提供的类中提供一个方法.

Create a new 'Android Instrumented Test' and you should set the module to app, and the class to the path name of your ui test class. You can even choose the 'Method' option and provide a method within the class provided in the path.

希望这会有所帮助.这是Android Studio中一个非常令人讨厌的错误,它使我的测试花费了一些时间.

Hope this helps. This was a very annoying bug in Android Studio that was taking time off of my testing.

干杯!

这篇关于“未找到测试".在Android UI测试期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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