cashapp / paparazzi

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

Add support for non unit test code in the Paparazzi plugin #1275

Closed mr-thierry closed 9 months ago

mr-thierry commented 9 months ago

I have a project with multiple modules. Each modules is a UI component of the Android app.

I created a custom TestRule named FooTestRule. It works fine if the test rule is next to a snapshot test in a test folder.

But I want to share FooTestRule with every Paparazzi tests in every modules. I tried two ways to share this TestRule:

  1. Put it under src/testFixtures/java/
  2. Create a 'common' Android module and put the FooTestRule under /src/main/java.

This TestRule imports for example com.android.ide.common.rendering.api.SessionParams.RenderingMode.SHRINK. But this import doesn't work when I move FooTestRule under src/testFixtures/java/ or /src/main/java. My guess is that Paparazzi only adds the dependencies to the tests(which makes sense in a way). But I would like to be able to configure that.

TWiStErRob commented 9 months ago

See https://github.com/TWiStErRob/net.twisterrob.sun/tree/main/component/paparazzi Which is used here for example: https://github.com/TWiStErRob/net.twisterrob.sun/blob/main/feature/configuration/build.gradle.kts via https://github.com/TWiStErRob/net.twisterrob.sun/blob/main/gradle/plugins/src/main/kotlin/net/twisterrob/sun/plugins/PaparazziPlugin.kt#L16

mr-thierry commented 9 months ago

Note: adding a dependency to the Paparazzy library fixed my issue. It would be a good idea to put that in the documentation IMHO. :)

jrodbx commented 9 months ago

Closing as fixed per @TWiStErRob's response