From 96b1e1913bf600cc0bf6c9ee8949f790445ca795 Mon Sep 17 00:00:00 2001 From: Carter Jernigan Date: Mon, 11 Oct 2021 15:52:24 -0400 Subject: [PATCH] [#21] Enable test orchestrator --- app/build.gradle.kts | 13 +++++--- ...zcash.android-build-conventions.gradle.kts | 3 ++ build.gradle.kts | 32 +++++++++++++++++++ gradle.properties | 5 +-- settings.gradle.kts | 13 +++++--- ui-lib/build.gradle.kts | 15 +++++---- .../onboarding/view/OnboardingViewTest.kt | 2 +- .../screen/onboarding/view/OnboardingView.kt | 2 +- 8 files changed, 65 insertions(+), 20 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 569635d4..58a6a200 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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" + } + } + } } diff --git a/build-conventions/src/main/kotlin/zcash.android-build-conventions.gradle.kts b/build-conventions/src/main/kotlin/zcash.android-build-conventions.gradle.kts index d73b0202..ca65ebf5 100644 --- a/build-conventions/src/main/kotlin/zcash.android-build-conventions.gradle.kts +++ b/build-conventions/src/main/kotlin/zcash.android-build-conventions.gradle.kts @@ -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().apply { configureBaseExtension() diff --git a/build.gradle.kts b/build.gradle.kts index 38124d77..8fe2343c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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().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().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" + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index a9c998ea..04b5b43b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/settings.gradle.kts b/settings.gradle.kts index 76898050..47710c3f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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" ) ) } diff --git a/ui-lib/build.gradle.kts b/ui-lib/build.gradle.kts index bb03e1e3..8ca86680 100644 --- a/ui-lib/build.gradle.kts +++ b/ui-lib/build.gradle.kts @@ -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" + } + } + } } diff --git a/ui-lib/src/androidTest/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingViewTest.kt b/ui-lib/src/androidTest/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingViewTest.kt index 00a5f974..bcddd5a5 100644 --- a/ui-lib/src/androidTest/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingViewTest.kt +++ b/ui-lib/src/androidTest/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingViewTest.kt @@ -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 diff --git a/ui-lib/src/main/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingView.kt b/ui-lib/src/main/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingView.kt index 7ce8fb18..288966cd 100644 --- a/ui-lib/src/main/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingView.kt +++ b/ui-lib/src/main/java/cash/z/ecc/ui/screen/onboarding/view/OnboardingView.kt @@ -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