Software Development

Java – Compare XML files using XMLUnit

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

[wp_ad_camp_1]

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.

[wp_ad_camp_2]

Test Files

[wp_ad_camp_3]

The test files are as follow.

myxml.xml

expected_myxml.xml

[wp_ad_camp_4]

expected_myxml_new.xml

This is the file that does not match myxml.xml

[wp_ad_camp_5]

 

 

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like