Compare two xml files with Junit

I am writing a JUnit test case that wants to check if a specific file with some content has been added or not. In this case, I want to get an instance of the file before its modification and another instance of the file of the same file after the modification, and I want to check if both are equal. How to do it in Java Junit?

+3
source share
2 answers

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

XMLUnit can ignore whitespace and formatting, which I believe are immaterial and will also handle comparison

<stuff/>

and

<stuff></stuff> 
+4
source

XML (toString) .

0

Source: https://habr.com/ru/post/1769496/


All Articles