Closed saintmarina closed 1 year ago
Never mind, it was a modularization issue.
@saintmarina You are working on it right?. Because I have the same problem.
I have the same problem. It happens when I reference a resource that is outside of the module under test. I can reproduce it in HelloComposeTest
when I replace
val text = "Hello, Paparazzi"
with
val text = stringResource(some.other.module.R.string.hello) // define this string in another module
The same happens with drawable and color resources.
@juckrit @bartek-wesolowski a unit test module can't access resources of another module. testFixtures
are solving that problem. However, last I checked testFixtures weren't available for android kotlin modules. You can follow the JetBrains ticket here.
We ended up importing the module that is being tested into the paparazzi testing module (because we use robolectric, we had to conduct all the paparazzi tests in a separate module) with implementation
instead of testImplementation
.
Sidenote: testFixtures should be available to use in Kotlin modules, but the fixture classes themselves cannot be written in the Kotlin language.
@TWiStErRob yes, testFixtures are available to use in kotlin modules, however they are not available in android (application, library) kotlin modules.
@saintmarina How did you fix your issue? I am facing with the same problem. I have a Components library. I added a Screenshot test for a component in this library and it gives me this error. As soon as I move the test to a feature module then it works :/
Description Paparazzi test(both record and verify) fails when tested Compose component gets resources with
xxxResources()
(e.g.stringResources()
orpainterResources()
. Stack trace:Perhaps, the issue is related to #524.
Steps to Reproduce
class IconTest : BaseTest() { @Test fun typographyTitleSnapshot() { paparazzi.snapshot { MyIcon(tint = Color.White) } } }