feat: Add warning threshold support for image comparisons#135
Open
simonmeggle wants to merge 2 commits into
Open
feat: Add warning threshold support for image comparisons#135simonmeggle wants to merge 2 commits into
simonmeggle wants to merge 2 commits into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR introduces a warning threshold that allows executing an arbitrary keyword (for example
Set Tags foo:warn) when image differences fall between two thresholds.Background
Maps often consist of multiple overlays with data from different sources. Verifying that such maps are rendered correctly is a common use case for Synthetic Monitoring.
If a map layer is missing, a large number of pixels will differ. In such cases the comparison threshold can be configured so the test fails as expected.
However, geographic maps naturally change over time (new buildings, forests, roads, etc.). These small and expected differences should not necessarily trigger an immediate alert. In many cases, a warning would be more appropriate.
A separate WARN state in Robot Framework has been discussed several times in RF PRs and Slack discussions, but has not been introduced so far.
Approach
To address this, a new parameter
threshold_warnis introduced. When the comparison score exceeds this threshold but remains below the failure threshold, a user-defined keyword can be executed.The library import argument
run_keyword_on_warn_thresholdallows defining which keyword should run in this situation. This gives users full flexibility to decide how warnings should be handled (e.g. logging, tagging the test, or triggering additional actions).New Parameters
threshold_warn(keyword-level)Warning threshold for visual comparison (range
0.0–1.0).Differences between
threshold_warnandthresholdtrigger a warning but do not fail the test.run_keyword_on_warn_threshold(library-level)Robot Framework keyword (with optional arguments) that will be executed when the warning threshold is exceeded.
Behavior
score ≤ threshold_warn→ PASSthreshold_warn < score ≤ threshold→ PASS with warning + keyword executionscore > threshold→ FAIL (existing behavior)Validation
threshold_warnmust be less thanthresholdthreshold_warnmust be between 0.0 and 1.0ValueErroris raised if validation failsCompatibility
The implementation maintains full backward compatibility with existing tests.