I want to compare two xml strings in a test, but the test keeps failing due to whitespace.
@Test
public void testForEquality() throws Exception {
String myControlXML = "<msg><uuid>0x00435A8C</uuid></msg>";
String myTestXML = "<msg><uuid>0x00435A8C</uuid> </msg>";
assertXMLEqual(myControlXML, myTestXML);
Diff diff = new Diff(myControlXML, myTestXML);
assertTrue(diff.similar());
}
Yes, XMLUnit can ignore whitespaces. See API documentation for details. You can enable it by setting:
XMLUnit.setIgnoreWhitespace(true)