Menu

1 / 8

Why Your Compose Tests Started Failing: The v2 Test Dispatcher Explained

DEV Community: kotlin·Android Expert·about 6 hours ago
#Jz23nXhm
#devtokotlin#devto#dev#test#composerule
Reading 0:00
15s threshold

How a one-line import change exposes timing assumptions your test suite has quietly relied on for years

1. “My tests passed yesterday and nothing changed”

The diff that turned your CI red usually looks harmless. Maybe it’s one line per file:

- import androidx . compose . ui . test . junit4 . createComposeRule + import androidx . compose . ui . test . junit4 . v2 . createComposeRule

Enter fullscreen mode

Exit fullscreen mode

Someone accepted an IDE quick-fix for a deprecation warning. Or a Compose BOM bump plus allWarningsAsErrors = true made the deprecation fail the build, and a teammate ran a find-and-replace across the test source set. The production code didn't change, and neither did any assertions. Even so, 140 UI tests that had been green for two years now fail with messages like these:

java . lang . AssertionError : Expected : [ paywall_viewed ] but was : [ ] java . lang . AssertionError : Failed to assert the following : ( Text + EditableText contains 'Saved' ) expected : < Ready ( . . .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.