java - Comparing XMLs using XMLUnit RecursiveElementNameAndTextQualifier -


I am trying to compare 2 XML files using XMLUnit 1.2. I am using RecursiveElementNameAndTextQualifier () Qualifier

When changing the order of certain entities in my XML, XMLUnit causes passes in some cases and fails in other cases.

My XML file looks like this, and I am comparing it in a similar copy, which swaps the ordinary location of a peer of properties.

  & lt; Root & gt; & Lt; ENT & gt; & Lt; Price & gt; & Lt; Integer & gt; 1 & lt; / Integer & gt; & Lt; / Pricing & gt; & Lt; Price & gt; & Lt; Integer & gt; 2 & lt; / Integer & gt; & Lt; / Pricing & gt; & Lt; / ENT & gt; & Lt; ENT & gt; & Lt; Price & gt; & Lt; Integer & gt; 3 & lt; / Integer & gt; & Lt; / Pricing & gt; & Lt; Price & gt; & Lt; Integer & gt; 4 & lt; / Integer & gt; & Lt; / Pricing & gt; & Lt; / ENT & gt; & Lt; / Root & gt;  

When auto-swapping: with int: 2, in one of the XML files, the test fails. But when int: swapping with 4: it keeps passing.

Here is my test code:

  throws exception to public zero test exemplary () {InputSource xml1 = new input source ("xml1.xml"); InputSource xml2 = new input source ("xml2.xml"); Diff myDiff = new def (xml1, xml2); MyDiff.overrideElementQualifier (new recurring alignment name and textualifier ()); AssertXMlequal ("not equal", myDiff, is true); }  

Can you recommend the problem, and why XMLUnit first recognizes a difference in the case and not in the second case Is there a solution to this problem?

I have tried to reproduce the behavior you described, using the successful recursiveElementNameAndTextQualifier It does not matter in the order of time elements. So neither self-swapping: 1 and int: 2, and swapping int: 3 and int: 4 came out due to an error in my tests.

I do not know which behavior you would expect, but by replacing RecursiveElementNameAndTextQualifier in Element Nain and TextQuality, there was a claim error for both swapping cases.


Comments