takahirom / roborazzi

Make JVM Android integration test visible 🤖📸
https://takahirom.github.io/roborazzi/
Apache License 2.0
649 stars 24 forks source link

Screenshot capturing is very slow when there are many layers of UI components involved. #388

Closed jeiselvan closed 1 month ago

jeiselvan commented 1 month ago

Hello @takahirom!

I encountered an issue when there are many layer of UI components involved then the screenshot testing becomes very slow. I am using the latest Roborazzi version 1.18.0 and it takes around 5 mins to complete this one single test.

Not sure why this happens, but below is the content which I am trying to take the screenshot

captureRoboImage {
Box(
        modifier = Modifier
            .fillMaxSize()
    ) {
        ImageComponent(
            assetDrawableId = some image id,
            contentScale = ContentScale.Crop,
            modifier = Modifier
                .fillMaxSize()
        )
        Column(
            modifier = Modifier
                .align(Alignment.Center),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            ImageComponent(
                assetId = "some id",
                modifier = Modifier
                    .width(30.dp)
            )
             CircularProgressIndicator(
                color = Color.White,
                modifier = Modifier
                    .size(10.dp)
            )
        }
    }
}

I've disabled the animations in test options in gradle and I've reduced the scale of the image upon record to 0.5 as well in gradle properties (roborazzi.record.resizeScale=0.5) but no luck in reducing the overall time of the test execution.

takahirom commented 1 month ago

@jeiselvan I think it seems like a timeout is occurring. Could you try using a debugger to see where the process is getting stuck?

jeiselvan commented 1 month ago

Hey @takahirom

Yeah, it seems when I removed the CircularProgressIndicator everything seems to work faster. Tests executed within 10 sec.

takahirom commented 1 month ago

@jeiselvan You can set ComposeTestRule.mainClock.autoAdvance to false and use mainClock.advanceTimeBy(1_000). Alternatively, you can ignore those composable tests by checking if it is a unit test. https://stackoverflow.com/a/30713876