Does XMLUnit have an assert to ignore whitespace
Yes, XMLUnit can ignore whitespaces. See API documentation for details. You can enable it by setting: XMLUnit.setIgnoreWhitespace(true)
Yes, XMLUnit can ignore whitespaces. See API documentation for details. You can enable it by setting: XMLUnit.setIgnoreWhitespace(true)
For xmlunit 2.0 (I was looking for this) it is now done, by using DefaultNodeMatcher Diff diff = Diffbuilder.compare(Input.fromFile(control)) .withTest(Input.fromFile(test)) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build() Hope this helps this helps other people googling…
I wound up implementing a DifferenceListener that takes a list of node names (with namespaces) to ignore textual differences for: public class IgnoreNamedElementsDifferenceListener implements DifferenceListener { private Set<String> blackList = new HashSet<String>(); public IgnoreNamedElementsDifferenceListener(String … elementNames) { for (String name : elementNames) { blackList.add(name); } } public int differenceFound(Difference difference) { if (difference.getId() == DifferenceConstants.TEXT_VALUE_ID) … Read more