-
Notifications
You must be signed in to change notification settings - Fork 8
Home
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
- a DifferenceEngine that compares two pieces of XML
- a library that allows XPath expressions to be evaluated conveniently
- a library that allows documents or XML schemas to be validated easily - documents can be validated against DTDs as well
- a convenience layer for XSLT transformations
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.
- Overview
- General Concepts
- Comparing XML
- Validating XML
- Utilities
- Migrating from XMLUnit 1.x to 2.x
- Known Issues