dropbox / dropshots

Easy on-device screenshot testing for Android.
Apache License 2.0
257 stars 17 forks source link

[Request] Add tolerance #47

Closed vojtech-cerveny closed 1 year ago

vojtech-cerveny commented 1 year ago

Hey, I didn't find any option to add tolerance to snapshot. Do you think that it would be possible to add?

We have some chart changing in time and we don't care if it is pixel perfect - for example here

java.lang.AssertionError: "ICanSeeGraph" failed to match reference image. 135 pixels differ (0.00366482 %)

It would be nice to have option for that.

JayShortway commented 1 year ago

Hi @vojtech-cerveny, you can use a custom ResultValidator for that. The built-in ThresholdValidator seems to be what you're looking for. You can use it like this:

@get:Rule
val dropshots = Dropshots(
    resultValidator = ThresholdValidator(threshold = 0.01f),
)

Let me know if this answers your question!

vojtech-cerveny commented 1 year ago

Hey, yup, this is it! Thanks, it wasn't clear from documentation how to use that. It works properly, thanks!