指定测试的依赖与Android的摇篮构建系统 [英] Specifying test dependencies with the Gradle Android build system

查看:197
本文介绍了指定测试的依赖与Android的摇篮构建系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想指定我的测试和阅读摇篮依赖管理基础我之后的依赖虽然我可以只添加 testCompile 调用我的依赖声明是这样的:

  {相关性
    编译组:com.squareup.dagger',名称:匕首,版本:1.0.0
    testCompile组:'JUnit的',名称:'JUnit的版本:4.11
    testCompile组:com.squareup',名称:巨星-Android的版本:1.0.1
}

然而,失败,此错误消息:

 >找不到方法testCompile()为参数[{组= JUnit中,名称= JUnit中,版本= 4.11}]项目:simstatus。

我失去了一些东西在这里?

参考的gradle全面构建文件)


解决方案

Android编译系统不使用标准的摇篮的Java插件。

其文档说:


  

正如前面提到的previously,毗邻主要sourceSet是androidTest sourceSet,默认情况下位于的src / androidTest /


  
  

此外,在sourceSet可以被配置成具有其自己的依赖关系。
  默认情况下,应用程序和其自己的依赖被添加到测试应用程序的类路径,但是这可以使用被扩展


  {相关性
    androidTestCompile'c​​om.google.guava:番石榴:11.0.2
}

I want to specify dependencies for my tests and after reading the Gradle Dependency Management Basics I though I could just add testCompile calls to my dependency declarations like this:

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'
}

This, however, fails with this error message:

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

Am I missing something here?

(Full gradle build file for reference)

解决方案

The android build system doesn't use the standard Gradle Java plugin.

Its documentation says:

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'
}

这篇关于指定测试的依赖与Android的摇篮构建系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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