0

我使用 XUnit。对我来说这是两个相同的 XML,但是测试失败了。如何使用 Xunit 比较它们?或者是其他东西?

public void testIdentical() throws Exception {
        String myControlXML = "<struct>" +
                "<int a=\"1\"></int>" +
                "<int a=\"2\"></int>" +
                "</struct>";
        String myTestXML = "<struct>" +
                "<int a=\"2\"></int>" +
                "<int a=\"1\"></int>" +
                "</struct>";
        Diff myDiff = new Diff(myControlXML, myTestXML);
        assertTrue("my test" + myDiff, myDiff.similar());
}

java.lang.AssertionError: my test org.custommonkey.xmlunit.Diff
[different] Expected attribute value '1' but was '2' - comparing <int a="1"...> at /struct[1]/int[1]/@a to <int a="2"...> at /struct[1]/int[1]/@a
4

1 回答 1

0

这看起来像 XmlUnit 中的一个错误。从他们的文档中:

如果两个文档包含相同的元素和属性而不考虑顺序,则它们被认为是“相似的”。

在将它们传递给 Diff 之前,您可以尝试重新格式化它们以应用特定的规范命令。

于 2014-05-11T22:23:34.173 回答