Repository navigation
test: migrate device tests to v2 Compose test rules - #9
Merged
Merged
Conversation
The v1 rules run effects on an UnconfinedTestDispatcher, so a LaunchedEffect that resumes after withContext(Dispatchers.IO) can write Compose state off the main thread and lose the update on slow CI emulators. The v2 rules use StandardTestDispatcher. Also attach FailureCapture to every compose device test so failure screenshots and semantics dumps land in the managed-device additional output.
thisislvca
force-pushed
the
test/compose-v2-rules
branch
from
October 17, 2026 21:47
421865b to
2c4f39b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The v1 Compose test rules run effects on an UnconfinedTestDispatcher. A LaunchedEffect that resumes after
withContext(Dispatchers.IO)then continues inline on the IO thread and writes Compose state off the main thread; on slow software-rendered CI emulators that update is sometimes lost (the DemoReviewGapsTest sheet stuck on its spinner while logcat showed the data had arrived). Production resumes on the main thread, so this is a test-only fix; no app code changed.What
createAndroidComposeRule,createComposeRuleimports toandroidx.compose.ui.test.junit4.v2.*(21 files).StateRestorationTesterhas no v2 variant in this Compose version and still works with the v2 rule.FailureCaptureto every compose device test (it was only on GalleryNavigationTest and DemoReviewGapsTest, which is why failure-*.png / -semantics.txt were absent from CI artifacts for other failures). Verified locally that a failing test's output lands inapp/build/outputs/managed_device_android_test_additional_output/debug/<device>/, a path the CI upload step already collects.Verification
Full app suite on
pixel2Api30(106 tests) andpixel2Api36(111 tests), hardware GPU (-gpu host, SurfaceFlinger reports Apple M4 Pro / Metal): 0 failures.