mit einem Klick
screenshot-tests
// Use when writing or running Paparazzi screenshot tests in stripe-android — covers PaparazziRule setup, recording/verifying commands, and test structure
// Use when writing or running Paparazzi screenshot tests in stripe-android — covers PaparazziRule setup, recording/verifying commands, and test structure
| name | screenshot-tests |
| description | Use when writing or running Paparazzi screenshot tests in stripe-android — covers PaparazziRule setup, recording/verifying commands, and test structure |
We use Paparazzi for screenshot testing via the screenshot-testing module.
Record (update) screenshots after UI changes:
./gradlew :<module>:recordPaparazziDebug
To record a specific test class only:
./gradlew :<module>:recordPaparazziDebug --tests "com.stripe.android.package.MyScreenshotTest"
Wildcard form also works:
./gradlew :<module>:recordPaparazziDebug --tests "*.MyScreenshotTest"
New or updated screenshots are written to <module>/src/test/snapshots/images/ and added to the Git staging area.
Verify screenshots match recorded baselines (used on CI):
./gradlew :<module>:verifyPaparazziDebug
Failure diffs are written to <module>/out/failures (git-ignored).
internal class MyScreenshotTest {
@get:Rule
val paparazziRule = PaparazziRule(
SystemAppearance.entries, // Light/Dark
PaymentSheetAppearance.entries, // Default/Custom/Crazy appearances
FontSize.entries, // Default/Large font
boxModifier = Modifier.padding(horizontal = 16.dp),
)
@Test
fun testDefault() {
paparazziRule.snapshot {
MyComposable(/* ... */)
}
}
}
PaparazziRule generates all permutations of the config options automatically.<package>_<class>_<method>[<permutation>].png.| Option | Values | Import |
|---|---|---|
SystemAppearance | LightTheme, DarkTheme | com.stripe.android.screenshottesting |
FontSize | DefaultFont, LargeFont | com.stripe.android.screenshottesting |
PaymentSheetAppearance | DefaultAppearance, CustomAppearance, CrazyAppearance | com.stripe.android.utils.screenshots |
-Precord or other flags — Paparazzi uses a separate recordPaparazziDebug task, not a project property.testDebugUnitTest to record — this only verifies against existing snapshots; use recordPaparazziDebug to update them.src/test/snapshots/images/ and must be committed.Use when writing NetworkRule integration tests in stripe-android — covers testBodyFromFile, inline JSON modification, request matchers, and fixture patterns
Use when writing Compose UI tests in stripe-android — covers composeRule setup, Robolectric annotations, node assertions, and test tag patterns
Use when writing or structuring unit tests in stripe-android — covers runScenario pattern, fakes, Turbine Flow testing, and Truth assertions
Use when creating a fake test implementation in stripe-android — covers FakeClassName pattern, Turbine call tracking, ViewActionRecorder, and ensureAllEventsConsumed validation