【发布时间】:2018-06-25 10:45:54
【问题描述】:
我有以下方法:
public static void assertXMLEquals(String expectedXML, String actualXML) throws Exception {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));
List<Difference> allDifferences = diff.getAllDifferences();
Assert.assertEquals("Differences found: " + diff.toString(), 0, allDifferences.size());
}
来自班级:http://www.xmlunit.org/api/java/2.4.0/org/custommonkey/xmlunit/Diff.html
如果有差异,它会打印出来,例如:
[different] Expected attribute value 'false' but was 'true' - comparing <attribute name="false"...> at //journey[1]/attribute[1]/@name to <attribute name="true"...> at /journeyDetails[1]/journey[1]/attribute[1]/@name
有没有办法可以覆盖它来打印行号?
【问题讨论】:
-
抱歉,我误读了您的帖子并指出了另一个 Javadoc,因为我认为您使用的是 2.x API 而不是旧版 API。
标签: java xml junit tostring xmlunit