使用Gradle Android构建系统指定测试依赖关系

我想指定依赖关系我的测试和阅读Gradle Dependency Management Basics后,虽然我可以只是添加testCompile调用我的依赖声明如下:

dependencies {
    compile group: 'com.squareup.dagger', name: 'dagger', version: '1.0.0'


    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'com.squareup', name: 'fest-android', version: '1.0.1'
}

但是,这会失败,并显示此错误消息:

> Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.11}] on project ':simstatus'.

我在这里缺少什么?

(Full gradle build file for reference)

android构建系统不使用标准Gradle Java插件。

Its documentation说:

As mentioned previously, next to the main sourceSet is the androidTest sourceSet, located by default in src/androidTest/

Additionally, the sourceSet can be configured to have its own dependencies.
By default, the application and its own dependencies are added to the test app classpath, but this can be extended with

dependencies {
    androidTestCompile 'com.google.guava:guava:11.0.2'
}
http://stackoverflow.com/questions/16637608/specifying-test-dependencies-with-the-gradle-android-build-system

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:使用Gradle Android构建系统指定测试依赖关系