You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
We'd like to create our own rule to wrap some boiler plate code and help adopting some good practice by our users. One of it is to build snapshot test that cover font scale on device. Since the fontScale can only be set on the DeviceConfig I ended with a custom test rule that delegate to 2 Paparazzi rules (see code). When the test run we get a NPE because of initialization code.
app.cash.paparazzi.sample.ScaledTextTest > compositeItems FAILED
java.lang.NullPointerException
at app.cash.paparazzi.Paparazzi.takeSnapshots(Paparazzi.kt:285)
at app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:216)
at app.cash.paparazzi.Paparazzi.snapshot$default(Paparazzi.kt:215)
at app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:211)
at app.cash.paparazzi.sample.MyPaparazziRule.snapshot(MyPaparazziRule.kt:39)
at app.cash.paparazzi.sample.MyPaparazziRule.snapshot$default(MyPaparazziRule.kt:34)
at app.cash.paparazzi.sample.ScaledTextTest.compositeItems(ScaledTextTest.kt:14)
isInitialized is true for the second Paparazzi rule giving it an invalid state.
Also a side question I guess would be, how would you recommend to approach testing on variants that are at the DeviceConfig level. Ultimately we want our user to write the test once and have multiple snapshot per DeviceConfig property we care about.
Btw, I just realized to solve the fontScale (or any attribute from the DeviceFactor) you can use @TestParameter at the test class level (see https://github.com/google/TestParameterInjector).
So paparazzi might just need a better error message than the NullPointerException noted here.
For anyone interested in tackling this, the proposed approach would be to figure out the root cause of the NPE and allow multiple instances of Paparazzi to run without interfering with each other. This is especially important for the SDKifying effort.
Description
We'd like to create our own rule to wrap some boiler plate code and help adopting some good practice by our users. One of it is to build snapshot test that cover font scale on device. Since the
fontScale
can only be set on theDeviceConfig
I ended with a custom test rule that delegate to 2Paparazzi
rules (see code). When the test run we get a NPE because of initialization code.isInitialized
istrue
for the secondPaparazzi
rule giving it an invalid state.Also a side question I guess would be, how would you recommend to approach testing on variants that are at the
DeviceConfig
level. Ultimately we want our user to write the test once and have multiple snapshot perDeviceConfig
property we care about.Steps to Reproduce
This branch https://github.com/eboudrant/paparazzi/tree/multiple_paparazzi contains a new test
app.cash.paparazzi.sample.ScaledTextTest
Expected behavior
Not crash, the test output would be 2 images
Additional information:
The text was updated successfully, but these errors were encountered: