Specifying test dependencies with the Gradle Android build system

前端 未结 2 780
终归单人心
终归单人心 2020-12-09 15:33

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 dependen

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 15:53

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

    Update

    As of May 2017 Doc, testCompile is deprecated and you should use testImplementation

    dependencies {
            androidTestImplementation 'com.google.guava:guava:11.0.2'
    }
    

提交回复
热议问题