Closed DPGLuke closed 11 months ago
@DPGLuke What you are describing is a requirement of Paparazzi (that it only works in library modules). I'll make sure to add this info when I complete my "Screenshot testing with Showkase" documentation which I'm currently working on.
Hi, I'm having the same issue, but your solution isn't working for me.
After all steps I get this error:
error: com.airbnb.android.showkase.processor.exceptions.ShowkaseProcessorException: Showkase was not able to find the root class that youpassed to @ShowkaseScreenshot. Make sure that you have configured Showkase correctly.
Do you have any suggestions on how to fix it?
Same issue here
@RadoslawGorczyca It sounds like you have a different issue, as suggested by the stack trace. If you'd like, open a separate issue and give me a bit more details about your setup. It does sound like something is not set up correctly.
@DPGLuke like you correctly pointed out, it does sound like the Paparazzi issue that you linked - https://github.com/cashapp/paparazzi/issues/657
I'm using the Paparazzi integration:
com.airbnb.android:showkase-screenshot-testing-paparazzi
When I try to run the test to generate screenshots, all of my composables which use resources fail with this error:
android.content.res.Resources$NotFoundException: Could not resolve resource value: XXX
I have a feeling this is related to https://github.com/cashapp/paparazzi/issues/657
Problem
This happens in a multi-module project, where I have:
module
app
- an application module - contains my@ShowkaseRoot
class, which was namedAppShowkase
. This module has dependencies on all the other project modules (exceptapp-test
):module
app-test
- a library module made specifically for Paparazzi, since Paparazzi only works in library modules - it just wrapsapp
. It contains myPaparazziShowkaseScreenshotTest
implementation class, and has a dependency onapp
module, so it can referenceAppShowkase
:When I ran Paparazzi to generate screenshots (
./gradlew app-test:testDebug
) I would get theCould not resolve resource value
error for every Composable that used a resource.Solution
The solution was for
app-test
to not use the ShowkaseRoot fromapp
. Instead,app-test
now declares its own@ShowkaseRoot
, and references that fromScreenshotTest
:I also had to remove the dependency
app-test
had onapp
. This was to avoid having multipleShowkaseRootModule
s inapp-test
- this seems to confuse the code generation ofShowkaseScreenshot
.This seems to work around the issue of resources not being available across modules, as I now don't have any
Could not resolve resource value
errors, and my screenshots generate perfectly!To do
Can we add some documentation for this somewhere in this library? I think this use-case (wrapping the 'root' application module in a library module for Paparazzi) will be fairly common, and I'd like to save someone else time so they don't have to discover this all by themselves.
Thanks for the great library by the way!