Android Studio 导入现有单元测试“无法找到检测信息" [英] Android Studio import existing unit tests "Unable to find instrumentation info"

查看:30
本文介绍了Android Studio 导入现有单元测试“无法找到检测信息"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试我们的 Android Studio 并测试一个在 Eclipse 中运行的项目.我已经编译了所有内容,应用程序将正常启动,但我无法启动和运行单元测试.我最终通过将我的应用程序 lib 文件夹添加为依赖项来编译它们,但我认为我的运行配置不正确,因为每当我运行测试时,我都会收到此错误

So I'm trying our Android Studio and testing a project that worked in eclipse. I got everything compiling and the application will launch just fine, but I can't get my unit tests up and working. I eventually got them compiling by adding my applications lib folder as a dependency, but I don't think my run configuration is right because whenever I run my tests I get this error

Installing <packagename>
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/<packagename>"
pkg: /data/local/tmp/<packagename>
Success


Running tests
Test running started
Test running failed: Unable to find instrumentation info for: ComponentInfo{<packagename>/android.test.InstrumentationTestRunner}
Empty test suite.

对于所有新来者,自从我最初发布此问题以来,Android Studio 的状态发生了很大变化,但许多有帮助的人继续发布了针对此错误的特定解决方案.我建议按活跃排序并首先查看最新答案.

To all new arrivals, the state of Android Studio has changed a lot since I initially posted this question, but many helpful people have continued to post their particular solution for this error. I'd advise sorting by active and checking out the newest answers first.

推荐答案

如果您在 build.gradle 中定义了 testInstrumentationRunner,例如:

If you have a testInstrumentationRunner defined in your build.gradle such as this:

android {
    defaultConfig {
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"

确保在运行配置窗口中,您在 Android Studio/IntelliJ 运行配置中使用完全相同的特定检测运行器"进行测试.

make sure that in the run configuration window you use the exact same "Specific instrumentation runner" in your Android Studio / IntelliJ run configuration for your test.

这篇关于Android Studio 导入现有单元测试“无法找到检测信息"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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