Questions tagged [xmlunit]

XMLUnit is an open source project which enables JUnit-style assertions to be made about the content and structure of XML.

XMLUnit extends and to enable unit testing of XML.

It compares a control XML document to a test document or the result of a transformation, validates documents, and compares the results of expressions.

XMLUnit for Java

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.

XMLUnit is available for and .

184 questions
0
votes
1 answer

XMLUnit Diff testing XPath when XML doc contains namespaces

I would like to compare 2 xml documents d1.xml
RaviReddy
  • 31
  • 2
0
votes
1 answer

XMLUnit: removing parent wrapper

Is there a way in XMLUnit 2 to make these two documents return as the same (or similar)? I can do some preprocessing to get the child nodes, but I wanted to see if this could be done directly with XMLUnit. Doc1: test Doc2: …
yellavon
  • 2,821
  • 12
  • 52
  • 66
0
votes
1 answer

How to ignore element order when diffing with XmlUnit

I have XML in the following format: A ... B ... ... ... I want to…
D.R.
  • 20,268
  • 21
  • 102
  • 205
0
votes
1 answer

How can I ignore non-existing node element in XML Comparison Result?

I am trying to compare PUT Request XML and GET Response XML. The following code works so good but according to the requirements some elements are only readable and therefore appears in GET Response XML file. How can I eliminate such a following…
limonik
  • 499
  • 1
  • 6
  • 28
0
votes
1 answer

SoapUI - Compare XML in mock dispatch script using XMLUnit & Groovy

In SoapUI 5.2.1 I am trying to apply assertions within my Mock Dispatch Groovy Script to compare that the XML received by the mock, matches my expected xml. I have seen references to using XMLUnit to achieve this. Does anyone have a full groovy…
MattG
  • 5,589
  • 5
  • 36
  • 52
0
votes
2 answers

How to compare two xmls by skipping few nodes?

I have two xmls in string format. Need to compare both of them by skipping few nodes. In the result only difference of node and corresponding values are required. Suppose I have the following two xmls : Message -1
vermaraj
  • 634
  • 3
  • 10
  • 34
0
votes
1 answer

xml-unit Correct element qualifier

This question is following my question limitations of xml unit . I’m wondering about the best element qualifier. Now I have created two sample XMLs. Unfortunately I mustn’t post the real ones. The attached ones don’t make any sense, but they are…
Michael Konz
  • 170
  • 15
0
votes
1 answer

Namespace issue in xpath using XMLUnit 1.6

I'm using XMLUnit 1.6 for testing my xsl trasfromations.Mentioned below are two sample tests. In test1(), xml is NOT having namespace. test1 is getting passed which is expected. In test2(), xml is having namespace and test is getting failed.I'm not…
Habin
  • 792
  • 1
  • 11
  • 21
0
votes
2 answers

limitations of xml unit

I’m trying to compare 2 XML files, which are similar (for testing I just changed the element order with a randomize-tool ) with XMLUnit. Are there any limitations of the max number of elements or the max complexity of elements and child…
Michael Konz
  • 170
  • 15
0
votes
1 answer

Compare two XML using XMLUnit by skipping few attributes of some TAGs

I'm working on this java API(XMLUuit.jar) from last few days. I want to compare two XML files by skipping few parameters of a XML tag using XMLUnit API. xyz xyz these two files…
0
votes
1 answer

Matching nested elements with different order and number format

I'm using xmlunit 2.2.1 with Java and have the following XMLs to match. The problem here is twofold: the order is not the same some of the numerical values may have trailing zeroes (e.g. 0.250000) For this reason ByNameAndTextRecSelector() doesn't…
Roland
  • 7,525
  • 13
  • 61
  • 124
0
votes
1 answer

XMLUnit - How to compare a self-closing tag to one which isn't?

I have two pieces of XML, a part of which is : 0 These are in different files which I am comparing using…
anuvab1911
  • 311
  • 3
  • 10
0
votes
0 answers

How to set the encoding format UTF8 for the XMLUnit API (org.custommonkey.xmlunit.XMLUnit)

I'm doing a XML comparison between 2 xml files. My xml files (to be compared) contains a UTF8 BOM (viz.., EF BB BF ) in it. So, when I'm try to invoke the Diff API (of org.custommonkey.xmlunit.XMLUnit.Diff) with UTF8 encoding then I'm getting an…
Ragu
  • 187
  • 1
  • 11
0
votes
1 answer

XmlUnit order based on value

I am comparing a saved example xml with a live marshalled xml in my JUnit testing. Validating the presence of a key value pair in the xml. I am making use of XmlUnit 2.1.0 specifically My xml is as follows:
robinjohnobrien
  • 1,092
  • 2
  • 11
  • 19
0
votes
2 answers

How to wisely compare two XML files in SoapUI?

I have a situation where two different webservice methods should return exactly the same XML file. Right now when I get those two responses I compare those XML files using XMLUnit framework which shows xpath location + differences in various nodes…
JMK
  • 199
  • 1
  • 2
  • 18