0

Java – Compare XML files using XMLUnit

Here, we’ll be using XMLUnit from www.xmlunit.org in a Maven project.

Include the following in your pom.xml

Unit Test

Create a unit test with two test methods. We’ll test 2 scenarios – same and different XMLs.

Test Files

The test files are as follow.

myxml.xml

expected_myxml.xml

expected_myxml_new.xml

This is the file that does not match myxml.xml