Closed BraisGabin closed 1 month ago
you can also prevent the test from failing by making it pass with my little work around:
paparazzi.gif(
hostView,
start = 0,
end = durationMillis,
fps = 30,
name = "frame"
)
using this little trick to make it verify right files:
private val isVerifying: Boolean =
System.getProperty("paparazzi.test.verify")?.toBoolean() == true
. . .
@get:Rule
val paparazzi = Paparazzi(
. . .
snapshotHandler = if(isVerifying) {
// This is to provide support for videos verification despite they are not doing it:
// 'Note: does not handle videos or its frames at the moment'
object : SnapshotHandler {
val originalVerifier = SnapshotVerifier(0.1)
override fun close() {
originalVerifier.close()
}
override fun newFrameHandler(
snapshot: Snapshot,
frameCount: Int,
fps: Int
): SnapshotHandler.FrameHandler {
var frame = 0
val snapshotWithNameSuffixIncreasing = mockk<Snapshot> {
every { name } answers {
// every two calls increase by 1
// there are two calls in newFrameHandler in toFileName method:
// name != null
// name.toLowerCase
"${snapshot.name} ${(frame++)/2}"
}
every { testName } returns snapshot.testName
every { timestamp } returns snapshot.timestamp
every { tags } returns snapshot.tags
every { file } returns snapshot.file
}
return originalVerifier.newFrameHandler(if(snapshot.name?.endsWith("frame") == true) {
snapshotWithNameSuffixIncreasing
} else snapshot, frameCount, fps)
}
}
} else {
HtmlReportWriter()
}
)
@radodado thanks for the workaround. I'm closing this PR as now with 1.3.4 we have support to verify gif
s so this is not longer important.
Description The
Paparazzi.gif
function fails with an exception when verifying. That's expected. The problem is that when I try to catch that exception to avoid failing I can't do it.A test like this always fails at the line
paparazzi.git(view)
but theprintln("exception captured composable!")
is executed because I can't see that output.The exception looks like this:
I know that it is expected that
paparazzi.gif(view)
will throw an exception. But I should be able to catch that exception and prevent the test failure.This error was present on 1.3.2 but now on 1.3.3 it's easier to reproduce/more consistent.
I imagine that this issue is related with #1309 and this comment: https://github.com/cashapp/paparazzi/pull/1309/files#r1507960495
Steps to Reproduce
./gradlew vPD
you will see that one of the two tests inExempleUnitTest.kt
will fail. Which one is not defined, it depends on which one is executed first. You can play changing the name of the tests to see that.Standard output
the output of bothcatch
is there.1.3.3
atbuild.gradle.kts
./gradlew vPD
again and you will see now than both tests fail.Expected behavior If
gif
throws an exception and I have atry/catch
around it I can capture it and prevent the test to fail.Context On
1.3.2
I had a workaround like that to mixsnapshot
andgif
in the same project. Even if thegif
s didn't verify it is better to have the golden snaphots and at least you will notice changes if that golden snapshots change. It is not ideal but it is better than nothing.Additional information: