xmlunit

XMLUnit ignoring version diffrences in links


I want to ignore similar urls with diffrent version or parameters.Is there a way to achieve that using XMLUnit?

Control XML:<script src="https://test.com/test.js?param=12345" type="text/javascript"/>

Test XML:<script src="https://test.com/test.js?param=123" type="text/javascript"/>

I want to ignore such diffrences while generating all diffrences.


Solution

  • You can tell XMLUnit to use a DifferenceEvaluator that you provide yourself.

    With this evaluator you'd return the original outcome unless it is an ATTR_VALUE comparison and you can identify it is the src attribute on a script element (look at the Comparison's control target and its parent) - in which case you return SIMIALR or even EQUAL.