<XmlUnit/>
Keywords: unit testing, test driven development, xml, xmlunit, junit, nunit

# XMLUnit - JUnit and NUnit testing for XML
For those of you who've got into it you'll know that test driven development is great. It gives you the confidence to change code safe in the knowledge that if something breaks you'll know about it. Except for those bits you don't know how to test. Until now XML has been one of them. Oh sure you can use `"<stuff></stuff>".equals("<stuff></stuff>");` but is that really gonna work when some joker decides to output a `<stuff/>`? -- damned right it's not ;-) XML can be used for just about anything so deciding if two documents are equal to each other isn't as easy as a character for character match. Sometimes
    <stuff-doc>
      <stuff>
        Stuff Stuff Stuff
      </stuff>
      <more-stuff>
        Some More Stuff
      </more-stuff>
    </stuff-doc>
| equals |
    <stuff-doc>
      <more-stuff>
        Some More Stuff</more-stuff>
      <stuff>Stuff Stuff Stuff</stuff>
    </stuff-doc>
and sometimes it doesn't... With XMLUnit you get the control, and you get to decide.
## XMLUnit for Java |
The current stable release is XMLUnit 1.5, September 2013. XMLUnit for Java provides two JUnit extension classes, `XMLAssert` and `XMLTestCase`, and 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.
Read the User's Guide (PDF or HTML) | See some example code | Browse the Javadocs | Visit the Subversion repository
## XMLUnit for .Net |
The current release is XmlUnit .Net 0.4, April 2009 XMLUnit for .Net provides NUnit extension classes written in C#, e.g. `XmlAssertion` and `XmlDiff`, that allow assertions to be made about the differences between two pieces of XML, the validity of a piece of XML, the evaluation of an XPath expression on a piece of XML, and the result of an XSL Transform. Please be aware that the .Net code base is not as advanced as its Java counterpart, in particular there is currently no explicit support for namespaces.
## News RSS feeds are available for Project news releases and Project file releases . An archive of the project news is available here.
Brought to you by Tim Bacon and Jeff Martin