unic / ScalaWebTest

ScalaWebTest is a library for writing ScalaTest/Selenium based integration tests for web applications. It helps you with your basic setup and provides a new and very efficient approach to testing.
https://scalawebtest.org
Apache License 2.0
29 stars 9 forks source link

Only report the closest match which didn't fit #39

Open DaniRey opened 7 years ago

DaniRey commented 7 years ago

In case we have the following HtmlElement

<select>
 <option value="foo">foo</option>
 <option value="bar1">bar</option>
</select>

and the following Gauge definition

elem fits(<option value="bar">bar</option>)

It would currently report Misfitting Attribute: [value] in [HtmlOption[<option value="foo">]] with value[bar] didn't equal [bar] Misfitting Attribute: [value] in [HtmlOption[<option value="bar1">]] with value[bar1] didn't equal [bar]

A human would immediately see, that the second element is what we where looking for, because the text is correct, but only the value attribute is off. While with the first candidate, both text and value are off.

If we would try every attribute instead of reporting a misfit, as soon as an attribute of the gauge definition doesn't fit, we could provide better Misfit reports.

In case we find a solution for this, we have to make sure it doesn't hurt performance too much. Maybe one could only execute the deeper analysis of misfits, in case the gauge doesn't fit.