Skip to main content

Jetpack Compose - basic test

With additional context

Data extraction

Native-first with AI fallback

Run your own Compose code first and let the SDK fall back to AI only when it throws. This is the pattern to reach for in a real suite: stable steps stay fast and deterministic, and a step that breaks because the UI moved keeps the test alive instead of failing it.
Keep the natural language command descriptive of what the native code does. It is the AI fallback and the label the step carries in the session recording, so "Tap the Sign In button" is worth more than "fallback".

Bulk assertions and checks

Verify several things against one screenshot rather than one call each. assertBulk fails the test when any condition is not met; checkBulk returns the results so you can branch on them.

Reporting the test result

Report the outcome so each run is recorded as passed or failed rather than as auto-completed, and so the session’s slot against your account’s parallel session limit is released as soon as the test ends. A JUnit TestWatcher sees both outcomes, and its failed hook hands you the throwable, so the dashboard gets the reason rather than a bare “Failed”.
The isInitialized guard matters: if setUp itself fails there is no driver to report through, and without it the watcher would throw over the real failure.

With CI metadata

Record what your CI knows and the SDK does not, so a session can be found again by it and reporting can be sliced by it.
Values are strings, so convert anything else before passing it. Keys are free-form apart from language and version, which the SDK reserves to report itself. An instrumentation test cannot read the CI environment directly, so feed the values in through buildConfigField in your build.gradle.kts, or through InstrumentationRegistry.getArguments() if you pass them with -Pandroid.testInstrumentationRunnerArguments.