Alex Styl
10/10/2025, 3:12 AMAlex Styl
10/10/2025, 3:13 AMJack Boswell
10/10/2025, 3:14 AMJack Boswell
10/10/2025, 3:15 AMAlex Styl
10/10/2025, 3:16 AMJack Boswell
10/10/2025, 3:37 AMWinson Chiu
10/10/2025, 3:45 AMWinson Chiu
10/10/2025, 3:46 AMJack Boswell
10/10/2025, 3:47 AMAlex Styl
10/10/2025, 3:52 AMJack Boswell
10/10/2025, 3:58 AMandroidx.compose.ui:ui-test-manifest:1.8.2
in your Android dependencies so that the empty Activity for tests to launch is available. Last I checked that needed to be in your main dependencies, not the test source dependencies. Not sure if that's still the case
The docs you linked correctly say you need to specify Android JUnit runner testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
But it misses the dependency you need for that androidx.test:runner:1.7.0
From there it should just work, but if it doesn't I most always have stacktraces to follow somewhere. If the runner crashed, it'll show up in logcat, it's not often I see the problem in build outputAlex Styl
10/10/2025, 4:05 AM// app/build.gradle.kts
kotlin {
androidTarget {
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) //<- add this
}
sourceSets {
androidInstrumentedTest.dependencies { // <- add this entire block
implementation("androidx.compose.ui:ui-test-junit4-android:1.8.2")
implementation("androidx.compose.ui:ui-test-manifest:1.8.2")
}
}
}
android {
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" // <- add this
}
}
Then move your test (or create new ones) at the commonTest directory. You can run your tests with ./gradlew core:connectedAndroidTest
PS: If your test runs but there is no report, check to see if you have an error like this in your console:
> Task :core:connectedDebugAndroidTest Tests on Pixel_6_-_35(AVD) - 15 failed: There was 1 failure(s). Test run failed to complete. Instrumentation run failed due to Process crashed. > Task :core:connectedDebugAndroidTest FAILED Build e74eb030-655f-4d24-bd9f-8e40db14964d is closed FAILURE: Build failed with an exception.
^ this means that the test process fails. I made this working by switching to a different emulator. (went from API lvl 36 to API lvl 27). This is probably an Android issue not a CMP issue, but worth mentioning.Alex Styl
10/10/2025, 4:09 AMandylamax
10/10/2025, 7:34 AMOliver.O
10/10/2025, 9:32 AMandylamax
10/10/2025, 9:59 AMOliver.O
10/10/2025, 10:32 AM./gradlew -Pandroid.testInstrumentationRunnerArguments.TEST_INCLUDE=com*sample*b* pixel2api30AndroidDeviceTest
(The next release will support dots in patterns.)
What still needs to be done is make the IDE plugin's editor gutter icons support instrumented tests.andylamax
10/10/2025, 11:00 AMOliver.O
10/10/2025, 11:01 AM