23

在我的 Android 应用程序中,我想在一个包中排除一些测试用例,以便我在文件中使用test任务。build.gradle例如:

apply plugin: 'com.android.library'

test{
     exclude '**/calltest/Summary.class'
}

如果同步项目我得到以下异常:

* What went wrong:
A problem occurred evaluating project ':SdkModule'.
> Could not find method test() for arguments [build_4g3vf7b615x3x1p7i9ty0pt1l$_run_closure1@73d026ca] on project ':SdkModule' of type org.gradle.api.Project.

如果我添加apply plugin : 'java'

CONFIGURE FAILED in 1s
The 'java' plugin has been applied, but it is not compatible with the Android plugins.

请帮助我。

4

2 回答 2

5

尝试为我的 Jenkins 构建生成 XML 测试报告时遇到类似问题。测试相关设置应该在testOptions. 我的文件:

android {
  testOptions {
    unitTests.includeAndroidResources = true
    unitTests.all {
        reports {
            junitXml.enabled = true
            html.enabled = false
        }
    }
}
于 2019-06-24T08:41:19.287 回答
0

代替

test {
    exclude '**/calltest/Summary.class'
}

尝试 groovy

tasks.withType(Test) {
    exclude '**/calltest/Summary.class'
}

在 kts

tasks.withType<Test> {
    exclude '**/calltest/Summary.class'
}
于 2022-01-05T11:05:24.797 回答