Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 509
M.A.Murali Avatar asked Jan 08 '19 09:01

M.A.Murali


People also ask

What is useJUnitPlatform?

useJUnitPlatform() Specifies that JUnit Platform should be used to discover and execute the tests.


2 Answers

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
        }
    }
}
like image 118
antygravity Avatar answered Oct 22 '22 01:10

antygravity


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")
}
like image 2
Ajesh Avatar answered Oct 21 '22 23:10

Ajesh