I am using XMLUnit for my JUnit tests and I would like to configure it so as to ignore differences related to alternative (but equivalent) rendering of certain types. E.g. 3.14
vs 3.140
for xs:float
fields. I guess a full solution would require the tests to be XSD-aware so that the type of each field is known and nuanced comparisons be made in all cases (e.g. true
/1
for xs:boolean
and perhaps even going so far as to account for default attribute values). At any rate, I am willing to accept workarounds so that I can get my tests running without all those false alarms.
An SSCCE (without the JUnit machinery for easier reproduction) is given below:
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.Diff;
class XMLTestCaseConcrete extends XMLTestCase {
}
public class FooMain {
public static void main(String args[]) throws Exception {
String s1 = "<a>180</a>";
String s2 = "<a>180.0</a>";
Diff diff = XMLUnit.compareXML(s1, s2);
System.out.printf("difference below:\n---------\n%s\n-------------\n", diff);
XMLTestCase xmlTest = new XMLTestCaseConcrete();
xmlTest.assertXMLEqual(s1, s2);
}
}
No comments:
Post a Comment