Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip test for specific build variant in Android+Gradle?

I have a specific build variant that is ONLY used for mock testing. I'd prefer not to run unit tests against this variant (but want to run them against other variants). Is there any way to inform gradle to skip unit testing for this specific variant?

like image 487
Eric Miles Avatar asked Aug 18 '14 17:08

Eric Miles


1 Answers

In my case I wanted to skip all unit testing from the release variant. It can be achieved doing this:

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

    return true;
}
like image 66
Felipe Duarte Avatar answered Sep 29 '22 18:09

Felipe Duarte