paparazzi
paparazzi copied to clipboard
Allow specifying raw file name
I run my tests based on java resource files using a parameterized test. So all my tests run from a single method.
This is problematic because Paparazzi will prepend the test package name, class name and method name to the output file. To make matters worse, the output file name is often too long since I use the FQN of the composable being screenshotted.
Specifying a name doesn't work as it only appends it to the default name.
There should be a way to specify the full file name without having the class name as a prefix.
Here is some code to illustrate the problem:
@RunWith(Parameterized::class)
class PaparazziScreenshotTests(private val test: TestCase) {
@get:Rule
val paparazzi = Paparazzi(...)
@Test
fun runTest() {
paparazzi.snapshot {
...
}
}
companion object {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun testCases() = listResources().map(::TestCase)
}
class TestCase(
val className: String,
val methodName: String,
) {
override fun toString(): String = buildString {
append(className)
append('.')
append(methodName)
}
}
}
This will generate files that look like this:
com.example_PaparazziScreenshotTests_runTest[com.example.SomeComposableKt.SomeComposable].png