Skip to content

test: migrate device tests to v2 Compose test rules - #9

Merged
thisislvca merged 1 commit into
mainfrom
test/compose-v2-rules
Oct 17, 2026
Merged

thisislvca merged 1 commit into
mainfrom
test/compose-v2-rules

Conversation

@thisislvca

Copy link
Copy Markdown
Owner

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

  • Switch all createAndroidComposeRule, createComposeRule imports to androidx.compose.ui.test.junit4.v2.* (21 files). StateRestorationTester has no v2 variant in this Compose version and still works with the v2 rule.
  • No test needed extra synchronization; no assertions, waits or timeouts changed. mainClock-driven animation tests (PhotoTransitionTest, GalleryPinchAnimationTest) are untouched and still step intermediate frames.
  • Attach FailureCapture to 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 in app/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) and pixel2Api36 (111 tests), hardware GPU (-gpu host, SurfaceFlinger reports Apple M4 Pro / Metal): 0 failures.

Base automatically changed from refactor/rename-to-alba to main October 17, 2026 21:46
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
thisislvca force-pushed the test/compose-v2-rules branch from 421865b to 2c4f39b Compare October 17, 2026 21:47
@thisislvca
thisislvca merged commit 43311f0 into main Oct 17, 2026
4 checks passed
@thisislvca
thisislvca deleted the test/compose-v2-rules branch October 17, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant