Basically you need to provide a DifferenceEvaluator that knows when your text difference is really comparing numbers - probably based on the element name of the parent or the name the attribute that is the target of the current comparision. Have this DifferenceEvaluator try to parse the text as a number and then perform a numeric comparison.
thank you very much. After a week of back and forth discusion with the stake holders we are going to leave this as it is cause 42 and 42.0000 are different ... :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have to ignore differences such as
Expected text value '1.3440000000000001E1' but was '13.44'.
I have multiple such nodes with that kind of difference- so I can't predetermine which node will have that kind of values.
I wish I had stakeholders like Hari Rao. :'-( , but that isn't the case and would appreciate some help.
<parent>
<child1>11.5 </child1>
<child2> 1.3440000000000001E1 <child2>
<child3> some string <child3>
</child3></child3></child2></child2></parent>
V/S
<parent>
<child1>11.5 </child1>
<child2>13.44 <child2>
<child3> some string <child3>
</child3></child3></child2></child2></parent>
Last edit: Jaspreet Singh Ahuja 2021-06-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But do you know which elements are expected to hold numbers? If so, you can still use the DifferenceEvaluator approach I described. Otherwise - if you don't know which elements are to be considered numbers how should XMLUnit know? :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Issues with comparing. 42 and 42.000000, 0.5 and 0.50 are considered different. Is there anything available to supress this behaviour?
Well, 42 and 42.0 are certainly different :-)
Basically you need to provide a
DifferenceEvaluatorthat knows when your text difference is really comparing numbers - probably based on the element name of the parent or the name the attribute that is the target of the current comparision. Have thisDifferenceEvaluatortry to parse the text as a number and then perform a numeric comparison.XMLUnit 1.x has something close in the examples folder - https://sourceforge.net/p/xmlunit/code/HEAD/tree/trunk/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java - which could be ported to the XMLUnit 2.x API as a
DifferenceEvaluatoreasily.thank you very much. After a week of back and forth discusion with the stake holders we are going to leave this as it is cause 42 and 42.0000 are different ... :)
I have to ignore differences such as
Expected text value '1.3440000000000001E1' but was '13.44'.
I have multiple such nodes with that kind of difference- so I can't predetermine which node will have that kind of values.
I wish I had stakeholders like Hari Rao. :'-( , but that isn't the case and would appreciate some help.
<parent>
<child1>11.5 </child1>
<child2> 1.3440000000000001E1 <child2>
<child3> some string <child3>
</child3></child3></child2></child2></parent>
V/S
<parent>
<child1>11.5 </child1>
<child2>13.44 <child2>
<child3> some string <child3>
</child3></child3></child2></child2></parent>
Last edit: Jaspreet Singh Ahuja 2021-06-29
But do you know which elements are expected to hold numbers? If so, you can still use the
DifferenceEvaluatorapproach I described. Otherwise - if you don't know which elements are to be considered numbers how should XMLUnit know? :-)