Skip to content

Instantly share code, notes, and snippets.

@opatry
Last active May 6, 2022 11:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opatry/6e018eef4e70bc0f82a3bc5d8b3b9f19 to your computer and use it in GitHub Desktop.
Save opatry/6e018eef4e70bc0f82a3bc5d8b3b9f19 to your computer and use it in GitHub Desktop.
CI Test execution on Android
subprojects {
afterEvaluate { proj ->
if (proj.hasProperty('android')) {
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
if (proj.hasProperty('kotlin')) {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
lintOptions {
abortOnError false
}
testOptions {
unitTests.all {
// let JUnit report mark the job status in case of error
ignoreFailures = true
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "short"
debug {
exceptionFormat "full"
}
}
}
}
}
}
if (proj.hasProperty('kotlin') && !proj.hasProperty('android')) {
compileKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
}
if (proj.hasProperty('test')) {
test {
// let JUnit report mark the job status in case of error
ignoreFailures = true
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "short"
debug {
exceptionFormat "full"
}
}
}
}
}
}
# `test` to trigger as much Jvm tests as possible
# `:app:testMyflavorDebugUnitTest` to restrict to only specific flavor(myflavor)+variant(debug) for `:app` module. If no flavor remove `Myflavor`.
# `-x :app:test` to remove all tests from `:app` module not being covered by `:app:testMyflavorDebugUnitTest`.
# `-x testRelease` to avoid triggering tests both in debug & release build.
# `-x :app:build` to avoid triggering useless build tasks (typically for unused flavors).
# Only rely on dependencies of `:app:testStandardDebugUnitTest`.
./gradlew clean test :app:testStandardDebugUnitTest -x :app:test -x testRelease -x :app:build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment