Imran Mammadli edited this page May 10, 2016 · 9 revisions

About XMLUnit 2.x

XMLUnit is a library available for Java and .NET that helps verifying pieces of XML contain what they are supposed to. Its main use is inside of Unit Tests where you verify content created by your program is valid XML, contains certain information or is the same as a certain reference XML document. At the same time its API strives to be general enough that it may be useful as a basis for XML diff tools or many other areas we haven't thought of.

XMLUnit 2.x is a complete rewrite of XMLUnit for Java 1.x that has been used widely. It offers a complete rewritten API (a more useful one we hope) but builds upon the ideas of 1.x. The migration guide highlights some of the differences.

The main parts of XMLUnit are

All of these libraries expect pieces of XML to be specified as "sources" - for Java this is a TrAX Source, for .NET an XMLUnit internal abstraction ISource - for details see "Providing Input to XMLUnit". A fluent builder API provides an easy way to create "sources".

For most parts we provide - or intend to provide - three different APIs to use them

  • a low level API that offers access to all features provided by the library
  • a fluent builder API built on top of that, which may cut short some of the features in order to be more convenient to use
  • Hamcrest Matchers and NUnit Constraints on top of that that strive to simplify writing unit tests

XMLUnit is split into a core library, the matchers/constraints are separate jars/assemblies. For Java there is an additional "legacy" jar that provides the API of XMLUnit 1.x on top of the 2.x implementation.