Skip to content

Support v2 Compose UI Tests APIs on non-android targets#2919

Merged
Konstantin (terrakok) merged 7 commits into
jb-mainfrom
CMP-9519
Mar 31, 2026
Merged

Support v2 Compose UI Tests APIs on non-android targets#2919
Konstantin (terrakok) merged 7 commits into
jb-mainfrom
CMP-9519

Conversation

@terrakok

@terrakok Konstantin (terrakok) commented Mar 25, 2026

Copy link
Copy Markdown
Member

Standardizing the testing infrastructure around StandardTestDispatcher and introducing "v2" test APIs to improve composition and coroutine handling in tests. It also includes refactoring of the recomposerCoroutineScope and adds validation for custom effect contexts.

Fixes:
CMP-9519 Implement ComposeUiTest v2 APIs and migrate the tests
CMP-2960 Support runComposeUiTest.effectContext argument
CMP-8849 Support to run on a StandardTestDispatcher

Release Notes

Features - Multiple Platforms

  • Support v2 Compose UI Tests APIs on non-android targets which uses StandardTestDispatcher by default instead of UnconfinedTestDispatcher
  • Support a customization of effectContext in Compose UI tests

Migration Notes - Multiple Platforms

  • runComposeUiTest, runSkikoComposeUiTest, runDesktopComposeUiTest are deprecated in favor v2 versions

@m-sasha Alexander Maryanovsky (m-sasha) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add tests that verify the new behavior (it should fail if you use UnconfinedTestDispatcher but succeed with StandardTestDispatcher. AOSP probably has them.

Also, we should run existing tests in TestBasicsTest using both old and new API.

@terrakok Konstantin (terrakok) merged commit 606484c into jb-main Mar 31, 2026
15 of 20 checks passed
@terrakok Konstantin (terrakok) deleted the CMP-9519 branch March 31, 2026 08:54

@igordmn Igor Demin (igordmn) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the new API, and also approve it (the PR contains Deprecated/new Experimental API in the CMP source sets)

@@ -44,14 +44,13 @@ import androidx.compose.ui.test.KeyInjectionScope
import androidx.compose.ui.test.onNodeWithTag

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support v2 Compose UI Tests APIs on non-android targets

Did we mention that the old API is deprecated anywhere? If not, we should mention this in this PR - this an important change affecting all multiplatform users.

The notes should look something like this:

## Features - Multiple Platforms
- Support `runComposeUiTest(effectContext=)`

## Migration Notes - Multiple Platforms
- `runComposeUiTest`, `runSkikoComposeUiTest`, `runDesktopComposeUiTest` are deprecated. Use `androidx.compose.ui.test.v2.runComposeUiTest` ... It uses `StandardTestCoroutineDispatcher` instead of `UnconfinedTestCoroutineDispatcher`

Please verify this note and fix mistakes before pasting it to the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants