# UI Testing

Writing UI tests is important to verify your UI layouts are implemented correctly. For example, you can take snapshots, compare them to your previous screens and track the differences.

In these docs, you'll learn how to write snapshot testing with [Paparazzi](https://cashapp.github.io/paparazzi/) and Stream Video's mock library.

## Set Up

First, you should import our `stream-video-android-previewdata` library to get mock instances and write your preview or test code for Stream Video UI components easily.

![Stream Video Android Previewdata](https://img.shields.io/maven-central/v/io.getstream/stream-video-android-previewdata.svg?label=Maven%20Central)

So add the dependency below below to your module's `build.gradle` file:

```groovy
dependencies {
    implementation "io.getstream:stream-video-android-previewdata:$stream_version"
}
```

Now, let's see how to write simple snapshot tests for Stream Video UI components.

```kotlin
class ScreenTests {

    @get:Rule
    val paparazzi = Paparazzi(deviceConfig = DeviceConfig.PIXEL_4A)

    fun snapshot(
        name: String? = null,
        isInDarkMode: Boolean = false,
        composable: @Composable () -> Unit
    ) {
        paparazzi.snapshot(name = name) {
            StreamPreviewDataUtils.initializeStreamVideo(LocalContext.current)
            CompositionLocalProvider(
                LocalInspectionMode provides true,
                LocalAvatarPreviewPlaceholder provides
                        io.getstream.video.android.ui.common.R.drawable.stream_video_call_sample
            ) {
                VideoTheme(isInDarkMode) { composable.invoke() }
            }
        }
    }

    @Test
    fun `snapshot CallContent component`() {
        snapshot(name = "CallContent") {
            CallContent(call = previewCall)
        }
    }

    @Test
    fun `snapshot CallLobby component`() {
        snapshot(name = "CallLobby") {
            CallLobby(
                modifier = Modifier.fillMaxWidth(),
                call = previewCall
            )
        }
    }
}
```

Let's break the code down line by line.

First, you should initialize Stream Video SDK with the `initializeStreamVideo()` method. You can learn more about our mock library on [UI Previews](/video/docs/android/ui-components/ui-previews/).

```kotlin
StreamPreviewDataUtils.initializeStreamVideo(LocalContext.current)
```

Next, you should enable `LocalInspectionMode` with the `CompositionLocalProvider` and allow Stream UI components to be rendered for the test environment.

```kotlin
CompositionLocalProvider(
    LocalInspectionMode provides true,
    LocalAvatarPreviewPlaceholder provides
            io.getstream.video.android.ui.common.R.drawable.stream_video_call_sample
) {
  ..
```

Finally, snapshot Stream Video components or your own Composable functions that contains Stream Video components like the example below:

```kotlin
@Test
fun `snapshot CallContent component`() {
    snapshot(name = "CallContent") {
        CallContent(call = previewCall)
    }
}
```

After running the command below, you'll see generated snapshots:

```bash
./gradlew recordPaparazziDebug
```

The snapshot images will look like this:

![Snapshot Images](/data/docs/video/android/_assets/portrait-video-five.png)


---

This page was last updated at 2026-03-04T14:25:31.677Z.

For the most recent version of this documentation, visit [https://getstream.io/video/docs/android/ui-components/ui-testing/](https://getstream.io/video/docs/android/ui-components/ui-testing/).