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

XMLUnit show added or removed nodes

I have two xml files like this: Test Test2 and this Test
Kevin
  • 785
  • 2
  • 10
  • 32
0
votes
0 answers

Comparing 2 XML files and getting all parent nodes

I'am using XMLUnit to compare two XML files(the only difference is in version): xmlunit xmlunit 1.4 and: xmlunit
JMK
  • 199
  • 1
  • 2
  • 18
0
votes
0 answers

XMLUnit outside unit test

I was wondering if I could use XMLUnit outside unit test, in my application ( to compare XML ). It seems intended for unit testing, so i feel like it should not be a good practice, but latest version of XMLUnit 2.0.0-alpha-3 seems to do exactly…
RoD
  • 464
  • 2
  • 11
  • 23
0
votes
1 answer

comparing two xmls using xmlunit ignorng their order

I have two xml files which I need to compare using xmlunit content of these xml files are always same except their order ex:
user3540481
  • 221
  • 3
  • 13
0
votes
1 answer

Can't register namespace with XMLUnit

I can't seem to work out how to set namespace when comparing XML's using xmlunit-2 Tried like: @Test public void testDiff_withIgnoreWhitespaces_shouldSucceed() { // prepare testData String controlXml = "Test…
learnAndImprove
  • 1,339
  • 4
  • 15
  • 25
0
votes
1 answer

comparing two XML with different number of elements using XMLUnit

I have two xmls, that needs to be compared. Number of elements in both the xml's may vary. Say for example consider below two xmls: XML1: David
Pramod
  • 731
  • 2
  • 10
  • 24
0
votes
1 answer

XMLUnit - ClassNotFoundException

I just downloaded XMLUnit (https://github.com/xmlunit/xmlunit/releases) but can't get it to work. When I tried to configure some properties like: XMLUnit.setControlParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); …
doughaase
  • 245
  • 4
  • 13
0
votes
0 answers

Customizing the DifferenceListener in XMLUnit

I want to modify the DifferenceListener in XMLUnit to ignore the attribute id while comparing XML files. I have tried to do it using the following. import org.custommonkey.xmlunit.DifferenceListener; import…
Debdipta Halder
  • 497
  • 1
  • 5
  • 19
0
votes
1 answer

How to use camel mock to get full XML?

In a unit test with camel, I can make asserts using xpath to check if the output xml is correct. But instead, I'd like to use XMLUnit to validate the xml against another entire xml file. Is that possible? The following test succeeds, but I'd like to…
Albert Hendriks
  • 1,979
  • 3
  • 25
  • 45
0
votes
1 answer

Java: XMLUnit.setIgnoreWhitespace(true) causing weird output

I have an issue in the following code. String xml1="COMPLETE" +"23"; String xml2="COMPLETE"; Diff diff = new…
Geek_Akash
  • 189
  • 1
  • 11
0
votes
5 answers

Meaningful XML comparison

I am trying to achieve meaningful XML comparison. I want to compare two different XML to know if they are 'meaningful' equal. Example XML 1: impiId
Faiz Ali
  • 141
  • 1
  • 11
0
votes
2 answers

Java XMLUnit comparing XML-files with different information ordering

I am trying to validate and check difference between two XML files. XML-file 1: XML-file…
henrik
  • 1,558
  • 3
  • 14
  • 29
0
votes
1 answer

Retrieve the element node from attribute node

For a node If current node is id (the attribute), how to retrieve Element node; i.e; a:cs?
unknown_boundaries
  • 1,482
  • 3
  • 25
  • 47
0
votes
1 answer

actual-<"null">,expected-<"null"> mismatch with XMLUnit

XMLUnit tries to match correct Entity elements (i.e. with correct attributes), but getting actual-<"null">,expected-<"null"> mismatch at <"Entity"> nodename. String expected = "" + "" + …
Venkatarao N
  • 245
  • 3
  • 14
0
votes
1 answer

What are the default DifferenceListener & matchTracker used by Diff of XMLUnit?

Default ElementQualifier is ElementNameQualifier, but what are the default DifferenceListener & MatchTracker?
Venkatarao N
  • 245
  • 3
  • 14