-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matcher doesn't ignore child elements if other than XPath #465
Comments
With my current understanding of your solution, that would extend the However, the more significant problem would be, that matchers might also be executed together with an attribute (e.g. My alternative solution would be: The origin, where the particular matcher for a single element (without attributes) is called, is the
or with Java 9+ 😢
Things to consider:
|
@diba1013 yeah, I really don't like the idea of a matcher enclosing state too. As you said, it then depends on the context it is being called from. A test capturing this behavior would look like: assertThat( matcher ).rejects( child );
assertThat( matcher ).accepts( parent );
assertThat( matcher ).accepts( child ); This is super confusing. We could walk the element tree upwards as you suggested, but as you already pointed out, this can be really, really expensive. I think there are several ways to approach this and we shouldn't rush for a decision—although the bug is quite critical—but carefully overthink the solution we want to go with. Regarding the XPath matcher: You mean |
Sure that should only be changed in conjunction with a solution to this bug. As stated, even then we might even consider leaving it as is in favor of performance, since string comparism is not fast for long strings, but considerably faster than walking the element tree (as we do not the complete |
Another approach:
This means linear time O(2n) = O(n), where n is the number of diffs in a test report. And we could compute this in a central place: Downsides? |
According to our docs:
This works fine when using an XPath, for example:
But when using a different matcher (i.e.
retestid
,id
,class
ortype
), child elements aren't ignored anymore. To verify this issue:I assume this is because in
ElementXPathMatcher
we do:This includes child elements because they share the same XPath prefix. However, this isn't the case for
retestid
,id
,class
ortype
. Here, we don't check if a parent has been ignored.A possible solution: Let all matchers also be a
ElementXPathMatcher
(e.g. via inheritance). Whenever such a matcher actually matches—for instance,ElementIdMatcher
finds an element with an ID that should be ignored—then we store the XPath too and incorporate this in subsequent invocations. Note that:id=foo
, where this element's XPath equalshtml[1]/[body[1]/div[1]/div[1]
. I don't believe this is the case, but if e.g. we check one of the child elements before we store the element-to-be-ignored's XPath, it won't be ignored.Other ideas?
The text was updated successfully, but these errors were encountered: