Class XMLAssert

java.lang.Object
junit.framework.Assert
org.custommonkey.xmlunit.XMLAssert
All Implemented Interfaces:
XMLConstants, XSLTConstants

public class XMLAssert extends junit.framework.Assert implements XSLTConstants
Collection of static methods so that XML assertion facilities are available in any class, not just test suites. Thanks to Andrew McCormick and others for suggesting this refactoring.
Available assertion methods are:
  • assertXMLEqual
    assert that two pieces of XML markup are similar
  • assertXMLNotEqual
    assert that two pieces of XML markup are different
  • assertXMLIdentical
    assert that two pieces of XML markup are identical. In most cases this assertion is too strong and assertXMLEqual is sufficient
  • assertXpathExists
    assert that an XPath expression matches at least one node
  • assertXpathNotExists
    assert that an XPath expression does not match any nodes
  • assertXpathsEqual
    assert that the nodes obtained by executing two Xpaths are similar
  • assertXpathsNotEqual
    assert that the nodes obtained by executing two Xpaths are different
  • assertXpathValuesEqual
    assert that the flattened String obtained by executing two Xpaths are similar
  • assertXpathValuesNotEqual
    assert that the flattened String obtained by executing two Xpaths are different
  • assertXpathEvaluatesTo
    assert that the flattened String obtained by executing an Xpath is a particular value
  • assertXMLValid
    assert that a piece of XML markup is valid with respect to a DTD: either by using the markup's own DTD or a different DTD
  • assertNodeTestPasses
    assert that a piece of XML markup passes a NodeTest
All underlying similarity and difference testing is done using Diff instances which can be instantiated and evaluated independently of this class.
See Also: