Skip to content

Commit

Permalink
Update tolerance docs and fix bug in tolerance comparison (#303)
Browse files Browse the repository at this point in the history
* Update README.md

* Make tolerance inclusive and fail only tests if the % of changes is bigger than the value configured
  • Loading branch information
pedrovgs authored Apr 23, 2022
1 parent ace0fd5 commit 3b1639d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ shot {
}
```
If you configure ``tolerance = 1`` it means the tolerance threshold will be 100% and all your tests will pass even if they should fail...so be careful when configuring this param.
If you configure ``tolerance = 100`` it means the tolerance threshold will be 100% and all your tests will pass even if they should fail...so be careful when configuring this param.
Take into account the ``instrumentationTestTask`` could be different if you use different flavors or build types. Remember also you should use Shot > 3.0.0 because this feature was introduced in this release!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ScreenshotsComparator {
val percentageOfDifferentPixels =
differentPixels.length.toDouble / oldScreenshotPixels.length.toDouble
val percentageOutOf100 = percentageOfDifferentPixels * 100.0
val imagesAreDifferent = percentageOutOf100 >= tolerance
val imagesAreDifferent = percentageOutOf100 > tolerance
val imagesAreConsideredEquals = !imagesAreDifferent
if (imagesAreConsideredEquals && tolerance != Config.defaultTolerance) {
val screenshotName = screenshot.name
Expand Down

0 comments on commit 3b1639d

Please sign in to comment.