[#21] Enable test orchestrator

This commit is contained in:
Carter Jernigan 2021-10-11 15:52:24 -04:00 committed by Carter Jernigan
parent 361c6a2eee
commit 96b1e1913b
8 changed files with 65 additions and 20 deletions

View File

@ -68,11 +68,6 @@ android {
}
}
// TODO [#5]: Figure out how to move this into the build-conventions
testCoverage {
jacocoVersion = libs.versions.jacoco.get()
}
// TODO [#6]: Figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
@ -93,4 +88,12 @@ dependencies {
implementation(projects.uiLib)
androidTestImplementation(libs.bundles.androidx.test)
if (project.property("IS_USE_TEST_ORCHESTRATOR").toString().toBoolean()) {
androidTestUtil(libs.androidx.test.orchestrator) {
artifact {
type = "apk"
}
}
}
}

View File

@ -1,3 +1,6 @@
// Note: due to a few limitations with build-conventions, there is some common Android Gradle Plugin
// configuration happening in the root build.gradle.kts with a subprojects block.
pluginManager.withPlugin("com.android.application") {
project.the<com.android.build.gradle.AppExtension>().apply {
configureBaseExtension()

View File

@ -56,3 +56,35 @@ fun isNonStable(version: String): Boolean {
return unstableKeywords.any { versionLowerCase.contains(it) }
}
// All of this should be refactored to build-conventions
subprojects {
pluginManager.withPlugin("com.android.library") {
project.the<com.android.build.gradle.LibraryExtension>().apply {
configureBaseExtension()
// TODO [#5]: Figure out how to move this into the build-conventions
testCoverage {
jacocoVersion = libs.versions.jacoco.get()
}
}
}
pluginManager.withPlugin("com.android.application") {
project.the<com.android.build.gradle.AppExtension>().apply {
configureBaseExtension()
}
}
}
fun com.android.build.gradle.BaseExtension.configureBaseExtension() {
// TODO [#22]: Figure out how to move this into build-conventions
testOptions {
animationsDisabled = true
if (project.property("IS_USE_TEST_ORCHESTRATOR").toString().toBoolean()) {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}
}
}

View File

@ -20,7 +20,7 @@ IS_COVERAGE_ENABLED=true
# Optionally configure test orchestrator.
# It is disabled by default, because it causes tests to take about 2x longer to run.
IS_USE_TEST_ORCHESTRATOR=false
IS_USE_TEST_ORCHESTRATOR=true
# Optionally disable minification
IS_MINIFY_ENABLED=true
@ -56,8 +56,9 @@ ANDROIDX_CORE_VERSION=1.6.0
ANDROIDX_ESPRESSO_VERSION=3.4.0
ANDROIDX_LIFECYCLE_VERSION=2.3.1
ANDROIDX_NAVIGATION_VERSION=2.3.5
ANDROIDX_TEST_VERSION=1.4.1-alpha03
ANDROIDX_TEST_JUNIT_VERSION=1.1.3
ANDROIDX_TEST_ORCHESTRATOR_VERSION=1.1.0-alpha1
ANDROIDX_TEST_ORCHESTRATOR_VERSION=1.4.1-alpha03
ANDROIDX_UI_AUTOMATOR_VERSION=2.2.0-alpha1
GOOGLE_MATERIAL_VERSION=1.4.0
JACOCO_VERSION=0.8.7

View File

@ -37,7 +37,8 @@ dependencyResolutionManagement {
val androidxEspressoVersion = extra["ANDROIDX_ESPRESSO_VERSION"].toString()
val androidxLifecycleVersion = extra["ANDROIDX_LIFECYCLE_VERSION"].toString()
val androidxTestJunitVersion = extra["ANDROIDX_TEST_JUNIT_VERSION"].toString()
val androidxTestOrchestratorVersion = extra["ANDROIDX_ESPRESSO_VERSION"].toString()
val androidxTestOrchestratorVersion = extra["ANDROIDX_TEST_ORCHESTRATOR_VERSION"].toString()
val androidxTestVersion = extra["ANDROIDX_TEST_VERSION"].toString()
val androidxUiAutomatorVersion = extra["ANDROIDX_UI_AUTOMATOR_VERSION"].toString()
val googleMaterialVersion = extra["GOOGLE_MATERIAL_VERSION"].toString()
val jacocoVersion = extra["JACOCO_VERSION"].toString()
@ -76,8 +77,10 @@ dependencyResolutionManagement {
//alias("androidx-espresso-contrib").to("androidx.test.espresso:espresso-contrib:$androidxEspressoVersion")
alias("androidx-espresso-core").to("androidx.test.espresso:espresso-core:$androidxEspressoVersion")
alias("androidx-espresso-intents").to("androidx.test.espresso:espresso-intents:$androidxEspressoVersion")
alias("androidx-junit").to("androidx.test.ext:junit:$androidxTestJunitVersion")
alias("androidx-testOrchestrator").to("androidx.test:orchestrator:$androidxTestOrchestratorVersion")
alias("androidx-test-core").to("androidx.test:core:$androidxTestVersion")
alias("androidx-test-junit").to("androidx.test.ext:junit:$androidxTestJunitVersion")
alias("androidx-test-orchestrator").to("androidx.test:orchestrator:$androidxTestOrchestratorVersion")
alias("androidx-test-runner").to("androidx.test:runner:$androidxTestVersion")
alias("androidx-uiAutomator").to("androidx.test.uiautomator:uiautomator-v18:$androidxUiAutomatorVersion")
alias("kotlinx-coroutines-test").to("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
@ -99,7 +102,9 @@ dependencyResolutionManagement {
listOf(
"androidx-espresso-core",
"androidx-espresso-intents",
"androidx-junit"
"androidx-test-core",
"androidx-test-junit",
"androidx-test-runner"
)
)
}

View File

@ -6,8 +6,6 @@ plugins {
id("zcash.android-build-conventions")
}
val packageName = "cash.z.ecc.ui"
android {
buildFeatures {
viewBinding = true
@ -18,11 +16,6 @@ android {
kotlinCompilerExtensionVersion = libs.versions.compose.get()
}
// TODO [#5]: Figure out how to move this into the build-conventions
testCoverage {
jacocoVersion = libs.versions.jacoco.get()
}
// TODO [#6]: Figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
@ -45,4 +38,12 @@ dependencies {
androidTestImplementation(libs.bundles.androidx.test)
androidTestImplementation(libs.androidx.compose.test.junit)
androidTestImplementation(libs.androidx.compose.test.manifest)
if (project.property("IS_USE_TEST_ORCHESTRATOR").toString().toBoolean()) {
androidTestUtil(libs.androidx.test.orchestrator) {
artifact {
type = "apk"
}
}
}
}

View File

@ -7,7 +7,7 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.filters.MediumTest
import cash.z.ecc.R
import cash.z.ecc.ui.R
import cash.z.ecc.ui.screen.onboarding.model.OnboardingStage
import cash.z.ecc.ui.screen.onboarding.state.OnboardingState
import cash.z.ecc.ui.screen.onboarding.test.getStringResource

View File

@ -18,7 +18,7 @@ import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import cash.z.ecc.R
import cash.z.ecc.ui.R
import cash.z.ecc.ui.screen.onboarding.model.OnboardingStage
import cash.z.ecc.ui.screen.onboarding.model.Progress
import cash.z.ecc.ui.screen.onboarding.state.OnboardingState