0

XMLUnit 尝试匹配正确的 Entity 元素(即具有正确的属性),但在 <"Entity"> 节点名处得到实际的-<"null">,预期的-<"null"> 不匹配。

    String expected = "<Object>" +
            "<Entity id=\"Entity1\">" +
            "expected1" +
            "</Entity>" +
            "<Entity id=\"Entity2\">" +
            "expected2" +
            "</Entity>" +
            "</Object>";
    String actual = "<Object>" +
            "<Entity id=\"Entity2\">" +
            "expected2" +
            "</Entity>" +
            "<Entity id=\"Entity1\">" +
            "expected1" +
            "</Entity>" +
            "</Object>";

这里有什么问题?提前致谢!

4

1 回答 1

0

它与节点顺序有关。很难通过失配细节的最终输出找到这一点。但我能够看到这一点DifferenceListener.differenceFound(Difference difference)。我们可以通过捕捉DifferenceConstances.CHILD_NODELIST_SEQUENCE_IDie来抑制它return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;

于 2015-03-27T07:15:09.913 回答