【发布时间】:2019-01-29 02:21:07
【问题描述】:
我按照gradle docs 在 Java 项目中按照测试类型分隔源文件,我想在 Android 库项目中做同样的事情。默认Android插件com.android.library支持test和androidTest两种测试目录。如何添加我想在 test 之后运行的 integTest?
sourceSets {
integTest {
java.srcDir file('src/integTest/java')
resources.srcDir file('src/integTest/resources')
}
}
当我尝试将上述sourceSet 添加到build.gradle 时,我收到错误
错误:Android 无法识别 SourceSet 'integTest' 梯度插件。也许你拼错了什么?
由于Android Gradle Plugin不像Java Plugin那样支持自定义sourceSets,有没有其他办法解决这个问题?
【问题讨论】:
-
androidTest.setRoot('integTest') -
那不是只在
integTest文件夹中查找测试文件吗?来自文档hereIf all the files for a source set are located under a single root directory, you can specify that directory using the setRoot property. When gathering sources for the source set, Gradle looks only in locations relative to the root directory you specify. For example, after applying the configuration below for the androidTest source set, Gradle looks for Java sources only in the src/tests/java/ directory.
标签: android gradle gradle-plugin source-sets android-sourcesets