Skip test for specific build option in Android + Gradle?

I have a specific build option that is ONLY used for prototyping. I would prefer not to run unit tests against this option (but want to use them for other options). Is there a way to tell gradle to skip unit testing for this particular option?

+4
source share
3 answers

In my case, I wanted to skip all unit tests from the release version. This can be achieved:

gradle.taskGraph.useFilter { task ->
    if (task.name.startsWith("test") && task.name.contains("ReleaseUnitTest")) {
        return false;
    }

    return true;
}
+1
source

Gradle allows you to call only those tasks that you specifically want to perform.

Gradle 'test' 'testReleaseVariant' ReleaseVariant. : "testReleaseVariant testFreeVariant" ..

"/" Android Studio, , " ". Gradle → "" "" "testReleaseVariant" , .

0

, taskGraph:

gradle.taskGraph.useFilter { task ->
    task.name != "testMock"
}

, , , , task.enabled = false , compileJava et al. .

0

All Articles