1.68.0
Compose Testing v2 (ui-test-junit4 v2) support (experimental)
If you've upgraded to Compose 1.11.0, where the v2 testing APIs (androidx.compose.ui.test.junit4.v2) are the default and the v1 rules are deprecated, Roborazzi now works with the v2 rule factories out of the box — createAndroidComposeRule from either package just works with RoborazziRule, captureRoboImage, and generated preview tests.
If you have a custom ComposePreviewTester, you can also delete the unchecked cast that used to be required:
override fun options(): ComposePreviewTester.Options = super.options().copy(
testLifecycleOptions = ComposePreviewTester.Options.JUnit4TestLifecycleOptions(
composeRuleFactory = {
// v1 or v2 createAndroidComposeRule both work; no cast needed anymore
createAndroidComposeRule<RoborazziActivity>()
},
...
)
)What you might need to change
Most users need no changes. The exception: the options APIs now accept the ComposeTestRule / ComposeContentTestRule interfaces instead of the concrete AndroidComposeTestRule<...> type, so composeTestRule.activityRule is no longer reachable through them. Roborazzi finds your rule's activity automatically; if it can't, it fails loudly (instead of silently capturing the wrong activity) and tells you to pass the scenario yourself:
composeTestRule(rule) { activityScenario }for direct capture callsJUnit4TestLifecycleOptions.activityScenarioProviderfor generated preview tests
The new sample-compose-v2 module shows both, running against stable Compose 1.11.0.
Compatibility
Libraries compiled against 1.67.0 keep working — the old entry points are preserved as hidden binary-compat bridges. If you compile against 1.68.0, typical code compiles as-is (or gets simpler, as above). Known remaining binary-level changes on these @ExperimentalRoborazziApi surfaces: JUnit4TestParameter.getComposeTestRule's return type and the data-class copy signatures of JUnit4TestLifecycleOptions / RoborazziComposeTestRuleOption; recompiling resolves them.
@PreviewWrapper previews now appear correctly in screenshots
If you use Compose UI 1.11's @PreviewWrapper to wrap previews in a theme or background, those wrappers now show up in your Roborazzi preview screenshots with no extra setup — just use ComposablePreviewScanner 0.9.0 or later (#823):
class DarkThemeWrapperProvider : PreviewWrapperProvider {
@Composable
override fun Wrap(content: @Composable () -> Unit) {
MaterialTheme(colorScheme = darkColorScheme()) { content() }
}
}
@PreviewWrapper(DarkThemeWrapperProvider::class)
@Preview
@Composable
fun WrappedPreview() { ... }This is verified by a sample preview test, and the docs have a new PreviewWrapper support section. Huge thanks to @sergio-sastre for implementing the automatic wrapping in ComposablePreviewScanner 0.9.0!
What's Changed
- Fill window in touch-robot sample so show-taps overlay aligns by @takahirom in #871
- Fix flaky desktop screenshot diffs by pinning runner and threshold by @takahirom in #872
- Abstract AndroidComposeTestRule to interfaces for Compose Testing v2 support by @takahirom in #816
- Restore 1.67.0 binary-compat constructors for JUnit4TestLifecycleOptions by @takahirom in #873
- Add Compose PreviewWrapper sample preview test by @takahirom in #874
Full Changelog: 1.67.0...1.68.0