Skip to content

Instantly share code, notes, and snippets.

@realdadfish
Last active January 27, 2020 08:22
Show Gist options
  • Save realdadfish/6db1a4fade396966e12172f94b174397 to your computer and use it in GitHub Desktop.
Save realdadfish/6db1a4fade396966e12172f94b174397 to your computer and use it in GitHub Desktop.
JVM Integration Tests with the Android Gradle Plugin. ATTENTION: Does not work!
android.applicationVariants.all { variant ->
configurations.create("${variant.name}IntegrationTestImplementation") {
extendsFrom configurations.find { it.name == "implementation" }
extendsFrom configurations.find { it.name == "${variant.name}Implementation" }
}
def sourceSet = android.sourceSets.create("${variant.name}IntegrationTest") {
// this fails here because `compileClasspath` is not existant in `AndroidSourceSet`
compileClasspath += variant.javaCompile.classpath
runtimeClasspath += variant.javaCompile.classpath
}
task "test${variant.name.capitalize()}IntegrationTest"(type: Test) {
description = "Runs integration tests for variant ${variant.name}"
group = 'verification'
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment