2013-11-21 33 views

回答

0

好吧,我發現這裏的解決方案 - http://xmlunit.sourceforge.net/userguide/XMLUnit-Java.pdf

對於EF法fi ciency原因DIFF只要第一個發現差別時停止比較過程。爲了獲得兩個XML片段之間的所有差異 DetailedDiff類的一個實例,需要一個Diff的子類。請注意,使用現有的Diff實例構建一個詳細的 Diff。

對於未來的讀者,這裏是解決方案(也鏈接 - 第9頁) -

DifferenceListener myDifferenceListener = new IgnoreTextAndAttributeValuesDifferenceListener(); 
    Diff myDiff = new Diff(expectedXML, actualXML); 
    myDiff.overrideDifferenceListener(myDifferenceListener); 
    Assert.assertTrue("test XML matches control skeleton XML", myDiff.similar()); 

再次鏈接,

The DifferenceEngine class generates the events that are passed to a DifferenceListener implementation as two 
pieces of XML are compared. Using recursion it navigates through the nodes in the control XML DOM, and determines which 
node in the test XML DOM qualifies for comparison to the current control node. The qualifying test node will match the control 
node’s node type, as well as the node name and namespace (if defined for the control node).