简体   繁体   中英

Could not find method test() for arguments on Android studio project

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.

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

Instead of

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

try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM