From ea4cff9ce4f51a82820d2b9c8fbde6ea3fd4ca16 Mon Sep 17 00:00:00 2001 From: Yang Date: Thu, 10 Jun 2021 19:27:42 +1000 Subject: [PATCH] Enable Unified gradle test runner and run tests with Unified gradle test runner without android-emulator-runner. --- .github/workflows/ci.yml | 10 ++-------- .../streamlined/BaselineProjectConfigs.kt | 14 ++++++++++++-- gradle.properties | 3 +++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 500179fe..0afe3297 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,14 +208,8 @@ jobs: script: echo "Generated AVD snapshot for caching." - name: Run Android instrumented tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 23 - arch: x86 - profile: Nexus 5X - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - script: ./gradlew connectedCheck + run: | + ./gradlew ui-home:pixel2api28DebugAndroidTest publish-to-play-store: name: Publish to Play Store diff --git a/buildSrc/src/main/kotlin/io/github/reactivecircus/streamlined/BaselineProjectConfigs.kt b/buildSrc/src/main/kotlin/io/github/reactivecircus/streamlined/BaselineProjectConfigs.kt index 1a0fb2f3..66a55253 100644 --- a/buildSrc/src/main/kotlin/io/github/reactivecircus/streamlined/BaselineProjectConfigs.kt +++ b/buildSrc/src/main/kotlin/io/github/reactivecircus/streamlined/BaselineProjectConfigs.kt @@ -1,5 +1,6 @@ package io.github.reactivecircus.streamlined +import com.android.build.api.dsl.ManagedVirtualDevice import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.LibraryAndroidComponentsExtension import com.android.build.gradle.TestedExtension @@ -9,6 +10,7 @@ import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestLogEvent +import org.gradle.kotlin.dsl.register import org.gradle.kotlin.dsl.repositories import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper @@ -57,10 +59,18 @@ internal fun TestedExtension.configureCommonAndroidOptions() { resourceConfigurations.add("en") } - testOptions.animationsDisabled = true - // TODO re-enable once lint analysis failure is fixed lintOptions.disable("DialogFragmentCallbacksDetector") + + testOptions { + animationsDisabled = true + devices.register("pixel2api28") { + device = "Pixel 2" + apiLevel = 28 + systemImageSource = "aosp" + abi = "x86" + } + } } /** diff --git a/gradle.properties b/gradle.properties index 08f14656..541f4c43 100644 --- a/gradle.properties +++ b/gradle.properties @@ -43,3 +43,6 @@ android.defaults.buildfeatures.renderscript=false android.defaults.buildfeatures.resvalues=false android.defaults.buildfeatures.shaders=false android.library.defaults.buildfeatures.androidresources=false + +# Enable Gradle managed virtual devices +android.experimental.androidTest.useUnifiedTestPlatform=true