每次我尝试运行测试时,控制台都会这样说:
Running tests
Test running startedTest running failed: Unable to find instrumentation info for:
ComponentInfo{com.employeeappv2.employeeappv2.test/android.test.InstrumentationTestRunner}
Empty test suite.
我已经被这个问题困扰了一段时间,到目前为止我在网上看到的解决方案都没有帮助。 我的项目结构是这样设置的:
*主模块 -src *仪器测试 -java *主要的 -java -显现 *build.gradle
我的 build.gradle 文件如下所示:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "2.1.0"
testPackageName "login.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/scandit.zip')
compile project(':pullToRefresh')
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.1+'
compile 'org.springframework.android:spring-android-rest-template:1.0.1+'
compile 'org.json:json:20090211'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.1'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.3.1'
compile 'com.android.support:support-v4:19.1.+'
compile 'com.mcxiaoke.volley:library:1.0.+@aar'
androidTestCompile 'junit:junit:3.8'
}
您的测试目录是否需要单独的 list ?如果是这样,那会是什么样子?
编辑:我尝试将 list 添加到我的 instrumentTest 目录,但没有成功。请注意,我无法让 IntelliJ 解析 targetPackage 名称,因此它显示为红色。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.employeeappv2.employeeappv2.src.instrumentTest"
android:versionCode="1"
android:versionName="1.0.0">
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.employeeappv2.employeeappv2.src.main"/>
</manifest>
最佳答案
当我尝试将 multiDexEnabled true
添加到 build.gradle
时,我遇到了同样的错误。
我在这里添加我的经验,因为这是在使用 ... 搜索时第一个 Google 命中... Unable to find ... ComponentInfo ...
错误消息。
在我的例子中,像这里添加 testInstrumentationRunner
就可以了:
...
android {
...
defaultConfig {
...
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
}
}
(我有 com.android.tools.build:gradle:1.5.0
)
关于android - 测试运行失败 : Unable to find instrumentation info for: ComponentInfo{} -- error trying to test in IntelliJ with Gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24002212/