cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.31k stars 215 forks source link

Ability to run test-projects verify/record tasks more easily #1659

Closed colinmarsch closed 3 weeks ago

colinmarsch commented 3 weeks ago

To regenerate the snapshots for tests in the test projects in the repo (e.g. paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/java/app/cash/paparazzi/plugin/test/ComposeA11yTest.kt) there isn't a straightforward way to run the record/verify tasks.

Right now, workarounds have to be done like changing this line in PaparazziPluginTest locally to be .withArguments("recordPaparazziDebug", "--stacktrace") and run ./gradlew paparazzi-gradle-plugin:test --tests PaparazziPluginTest.composeA11y to regenerate the snapshots or editing the run configuration of a test class (i.e. ComposeA11yTest) after running it within Android Studio.

It would be great if there was a simple way to run the verify and record tasks to update snapshots for the test projects when making changes to the code under test.

jrodbx commented 3 weeks ago

Right now, workarounds have to be done like changing this line in PaparazziPluginTest locally to be .withArguments("recordPaparazziDebug", "--stacktrace") and run ./gradlew paparazzi-gradle-plugin:test --tests PaparazziPluginTest.composeA11y to regenerate the snapshots or editing the run configuration of a test class (i.e. ComposeA11yTest) after running it within Android Studio.

That isn't a workaround, but rather the canonical way to do it.

A functional test requires using Gradle TestKit to invoke a Gradle process -- similar to what one does on the CLI. If a function test runs "verifyPaparazzi", then it's implied that the test already has golden files. If the golden want to be updated, you'll have to run "record" -- again, just like on the CLI.

colinmarsch commented 3 weeks ago

Ah gotcha, thanks for the context!