26

In my Android application, I want exclude some test cases in a package so that I used test task in build.gradle file. for example:

apply plugin: 'com.android.library'

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

If sync the project I got following exception:

* 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.

If I add apply plugin : 'java'

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

Please help me on this.

M.A.Murali
  • 9,988
  • 36
  • 105
  • 182

2 Answers2

6

Got similar problem when try to generate XML test report for my Jenkins build. Test related settings should be in testOptions. My file:

android {
  testOptions {
    unitTests.includeAndroidResources = true
    unitTests.all {
        reports {
            junitXml.enabled = true
            html.enabled = false
        }
    }
}
antygravity
  • 1,307
  • 10
  • 12
3

Instead of

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

try in Groovy

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

or in Kotlin DSL (build.gradle.kts)

tasks.withType<Test> {
    exclude("**/calltest/Summary.class")
}
Mahozad
  • 18,032
  • 13
  • 118
  • 133
Ajesh
  • 193
  • 8