Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare two xml files using Junit

I am writing a JUnit test case which want to test whether a particular file is added with some content or not. In that case, I want to get the instance of the file before modification and another file instance of the same file after modification and want to check whether both are not equal. how to do that in Java Junit ?

like image 708
Senthil Avatar asked Jul 27 '26 07:07

Senthil


1 Answers

There are tools that exist for this purpose, e.g. http://xmlunit.sourceforge.net/

XMLUnit can ignore whitespace and formatting which I would imagine are immaterial and will also handle comparing

<stuff/>

and

<stuff></stuff> 
like image 100
David Avatar answered Jul 30 '26 09:07

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!