Android的工作室单元测试:无法找到的仪器或类未找到前 [英] Android Studio Unit Testing: unable to find instrumentation OR class not found ex

查看:941
本文介绍了Android的工作室单元测试:无法找到的仪器或类未找到前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我有以下目录结构的Andr​​oid演播室内的测试套件:

I have a test suite within my Android studio that has the following dir structure:

-MainProject
 -src
  --com
  --tests
    --java.xx.xxx.xx.test

在我的Andr​​oidManifest,我有以下几点:

Within my AndroidManifest, I have the following:

<instrumentation
    android:name="android.test.InstrumentationTestRunner"
    android:targetPackage="tests.java.xxx.xxx.xxx.test" />

当我使用我的运行测试,在命令行: ./ gradlew connectedInstrumentTest ,我只是得到:

When I run my tests from the command line using: ./gradlew connectedInstrumentTest, I simply get:

Tests on Nexus 5 - 4.4.2 failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'

当我在Android Studio中运行测试,我得到:

When I run the tests from inside Android Studio I get:

Running tests
Test running startedTest running failed: Unable to find instrumentation info for: ComponentInfo{tests.xxx.xxx.xxx.xxx.test/android.test.InstrumentationTestRunner}
Empty test suite.

我也有在的build.gradle文件在我defaultConfig指定的testPackageName。我在Ubuntu 12.0.4运行Android工作室0.4.6。

I also have the testPackageName specified in my defaultConfig in the build.gradle file. Am running Android Studio 0.4.6 on Ubuntu 12.0.4.

任何想法?

推荐答案

我也得到错误像这样,我加入的build.gradle文件中的以下行所示的https://google.github.io/android-testing-support-library/docs/es$p$psso/setup/index.html和它的工作。我希望它也将帮助你: - )

I also get error like this and I added the following line in build.gradle file as shown in https://google.github.io/android-testing-support-library/docs/espresso/setup/index.html and it's working. I hope it will also help you :-)

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

这篇关于Android的工作室单元测试:无法找到的仪器或类未找到前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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