Posts

Showing posts from June, 2014

XMLUnit

XMLUnit for Java provides a set of supporting classes (e.g. Diff,  DetailedDiff, Transform, SimpleXpathEngine, Validator,NodeTest) that allow assertions to be made about: The differences between two pieces of XML The outcome of transforming a piece of XML using XSLT The evaluation of an XPath expression on a piece of XML The validity of a piece of XML Individual nodes in a piece of XML that are exposed by DOM Traversal XMLUnit for Java can also treat HTML content (even badly-formed HTML) as valid XML to allow these assertions to be made about the content of web pages too.   Experience I've used XMLUnit in 2 situations: assert that 2 xml files are semantically the same regardless of structural differences (eg. different formatting, different namespace prefixes, usage of opening and closing tag vs. empty tag...) and finding real differences between two xml files regardless of prior mentioned differences in structure. The equality of two