Cross-Library usage

AndroidUiTestingUtils provides out-of-the-box support to write screenshot tests that can run across libraries for Composables and Android Views

To configure cross-library screenshot tests, you need to follow the steps in this section.

Once done, write your tests like this:

  1. Define a ScreenshotTestRule with the default configuration, which can be overriden in your tests

fun defaultCrossLibraryScreenshotTestRule(
   config: ScreenshotConfigForComposable,
): ScreenshotTestRule =
    CrossLibraryScreenshotTestRule(config)
        // Optional: Define special configurations for each library you're using  
        .configure(
            ShotConfig(bitmapCaptureMethod = PixelCopy())
        ).configure(
            DropshotsConfig(
                bitmapCaptureMethod = PixelCopy(),
                resultValidator = ThresholdValidator(0.15f)
            )
        ).configure(
            AndroidTestifyConfig(bitmapCaptureMethod = PixelCopy())
        ).configure(
            PaparazziConfig(deviceConfig = DeviceConfig.NEXUS_4)
        ).configure(
            RoborazziConfig(
                filePath = File(userTestFilePath()).path,
                deviceScreen = DeviceScreen.Phone.NEXUS_4,
            )
        )
  1. Write a screenshot test

  1. or a parameterized screenshot test

Last updated