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
2
votes
2 answers

XMLunit compare only tags

I would like to compare two XML files, but based only on tag values, also I need to compare tags as a whole, e.g. text1 text2 what I need to…
Dzak
  • 201
  • 2
  • 12
2
votes
2 answers

XML file comparison in JAVA ignoring node order

I wanted to compare the xml files using JAVA and check if they are "equivalent". The below code works for me in 2 cases: When the xml files are exactly same. When the xml file has difference But fails when: XML files contain the same nodes but…
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
2
votes
1 answer

How to make XMLUNIT's WithNodeFilter dynamic C#

I am working on an app which compares XML files. The user may input a list of nodes in which they want to exclude in the comparison. For my comparison I am using XMLUNIT. I need to dynamically add the user input. The below code works, but is not…
Jordan Miller
  • 143
  • 1
  • 9
2
votes
1 answer

XMLUnit comparing ignoring the order of elements

I have 2 XML. I have been using XMLUnit for comparing the 2 xml strings. The problem is I am not able to ignore the order in which elements occur. I tried overriding ElementQualifier as well as DifferenceListener but that didn't help for this…
Akash Sateesh
  • 271
  • 2
  • 4
  • 13
2
votes
1 answer

Comparing XML documents in Java diff class - getting line number?

I have the following method: public static void assertXMLEquals(String expectedXML, String actualXML) throws Exception { XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); DetailedDiff…
java123999
  • 6,974
  • 36
  • 77
  • 121
2
votes
1 answer

Ignoring a particular attribute of a specific Node while comparing xml files using XMLUnit 2.X

I have two XML files: Experts Matrix Reminder
Ish
  • 136
  • 11
2
votes
1 answer

XMLUnit - NodeFilter does not return anything

I'm currently trying to work a bit with XML Unit. I have two documents, test and control that I want to compare. My scenario is that I only want to test two things(version and id) and ignore the rest. Here is what I have tried to do: final…
Prince of Sweden
  • 415
  • 7
  • 18
2
votes
1 answer

XMLUnit nested element testing

I have two XML files that I want to compare. I am using XMLUnit 2. But elements can be out of order (including sub element ordering) All three examples below need to be considered equivalent:
2
votes
2 answers

Using org.xmlunit.diff.NodeFilters in XMLUnit DiffBuilder

I am using the XMLUnit in JUnit to compare the results of tests. I have a problem wherein there is an Element in my XML which gets the CURRENT TIMESTAMP as the tests run and when compared with the expected output, the results will never match. To…
Kashyap Guru
  • 21
  • 1
  • 3
2
votes
2 answers

XMLUnit expected number of child nodes to be true but was false

I am using XMLunit to compare the following XML's XML 1 Some Text XML 2 Some Text I am expecting only element 2 to come in difference however I get a difference…
Anshul
  • 267
  • 1
  • 4
  • 13
2
votes
0 answers

Issue with XML comparison using XMLUnit

The two xmls I am trying to compare are: test ram test test2 textchange and
tanvi
  • 927
  • 5
  • 17
  • 32
2
votes
1 answer

How to compare 2 XML files and how to fetch the informations like newly Added\Removed elements using XMLUnit

I have 2 xml files with almost similar structure, In these XML files how to fetch the following informations ?? Controls (or Nodes) newly added Controls (or Nodes) removed and Control (or Nodes) properties modified. For your infomration, I tried…
Ragu
  • 187
  • 1
  • 11
2
votes
1 answer

How do I ignore order of identical elements with XMLUnit's DetailedDifference?

I want to compare two xml files using XMLUnit. I would like the DetailedDiff to not report identical tags in different orders as differences. For example, if I created a DetailedDiff with these two snippets: …
user3599828
  • 331
  • 8
  • 14
2
votes
2 answers

Ignore text differences when comparing XML with xmlunit

I have a problem in comparing xml strings. My compare function is public static boolean compareXMLs(String xmlSource, String…
Pasupathi Rajamanickam
  • 1,982
  • 1
  • 24
  • 48
2
votes
2 answers

XML Unit showing similar XML as false

XML1: xyz
Hoshang
  • 21
  • 2
1 2
3
12 13