As of com.android.tools.build:gradle:1.3.0 you can run into Task with name 'testDebug' not found in project ':module'.
As in the earlier stage of the build environment it was not possible to test library modules properly using Robolectric & Java this workaround was created:
afterEvaluate { project ->
    android.libraryVariants.each { variant ->
        println variant.name
        println tasks
        tasks.getByName("test${variant.name.capitalize()}") {
            dependsOn "assemble${variant.name.capitalize()}"
        }
    }
}
With version 1.3.0 this is broken.
They have changed the name from testDebug to testDebugUnitTest hence the code above needs to be changed to:
afterEvaluate { project ->
    android.libraryVariants.each { variant ->
        println variant.name
        println tasks
        tasks.getByName("test${variant.name.capitalize()}UnitTest") {
            dependsOn "assemble${variant.name.capitalize()}"
        }
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With