Open eboudrant opened 4 months ago
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.
Btw, I just realized ... you can use @TestParameter at the test class level...
Correct! We have an example for that here.
So paparazzi might just need a better error message than the NullPointerException noted here.
Agreed. A second instance of Paparazzi rule is invalid so that sounds like the appropriate fix here. Wanna submit a PR?
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: