From c01d1ba32bd61be426d12b0948b5a85b4601694a Mon Sep 17 00:00:00 2001 From: Paul Hitt Date: Fri, 4 Sep 2026 19:17:38 -0400 Subject: [PATCH] Fix: `./gradlew test` now passes on a clean tree (android#5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmed exactly as filed: 15 red `ScreenshotTest`s, all in the RELEASE variant, all "Unable to resolve activity for Intent". The diagnosis in the issue was right — `androidx.compose.ui:ui-test-manifest` is a `debugImplementation`, and it is what declares the `ComponentActivity` those tests launch, so the release variant's merged manifest has no such activity. ⚠️ **The tempting fix is to add that dependency to release as well. Do not.** It exists to inject a test-only activity into the manifest, so putting it on `releaseImplementation` would ship that into the APK. The tests belong to the variant that can run them. ⚠️ Excluded by name rather than by disabling `testReleaseUnitTest` wholesale — everything else still runs in both variants, so a genuine release-variant difference would still be caught. ⚠️ And the first green was not evidence: `clean` followed by `test` reported BUILD SUCCESSFUL in 3 seconds, which is far too fast to have run anything. Re-run with `--rerun-tasks` and counted: debug 129, release 114, JVM modules 933, 0 failures. The 15-test gap between the variants is exactly the excluded screenshot tests, which is the shape that proves the exclusion did what it says rather than taking the suite with it. Co-Authored-By: Claude Opus 5 --- app/build.gradle.kts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 92b653f..67ecfd1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -138,7 +138,32 @@ android { unitTests { isIncludeAndroidResources = true isReturnDefaultValues = true - all { it.systemProperty("robolectric.graphicsMode", "NATIVE") } + all { + it.systemProperty("robolectric.graphicsMode", "NATIVE") + + // 🔴 **The screenshot tests are debug-variant tests, and + // `./gradlew test` runs BOTH variants.** + // + // They launch a `ComponentActivity`, which is declared by + // `androidx.compose.ui:ui-test-manifest` — a `debugImplementation` + // dependency, so the release variant's merged manifest has no + // such activity and all fifteen die with "Unable to resolve + // activity for Intent". + // + // ⚠️ The tempting fix is to add that dependency to release as + // well. Do not: it exists to inject a test-only activity into + // the manifest, and putting it on `releaseImplementation` would + // ship that into the APK. The tests belong to the variant that + // can run them. + // + // ⚠️ Excluded by name rather than by disabling + // `testReleaseUnitTest` wholesale — everything else in the + // suite still runs in both variants, so a genuine + // release-variant difference would still be caught. + if (it.name.contains("Release")) { + it.exclude("**/ScreenshotTest*") + } + } } } } -- 2.54.0