私は受け入れテストから2つの属性をスキップしたかったので、2つの属性を削除するために次の部分を追加しました。これは私にエラーを与えます: junit.framework.AssertionFailedError:org.custommonkey.xmlunit.Diff [要素の数は '2' の属性が、XMLファイルの '1' がJavaでXMLUnitでテストから属性を削除するにはどうすればよいですか?
パートだった:
<a:content schemaVS="1"
a:schemaLocate="http://www.ContentXML.xsd"
whiteSpaceMode="preserve">
<section type="Chapter" id="drd121">
<p type="H1">This is H1.</p>
</section>
のJava実装の一部:
public Document removeIgnoredCxmlNodes(Document resultDocument) {
Element contentElement=(Element) resultDocument.getElementsByTagName("a:content").item(0);
contentElement.removeAttribute("schemaVS");
contentElement.removeAttribute("a:schemaLocate");
return resultDocument;
}
public void cxmlShouldBeProduced(String location) throws Throwable {
try {
Document expectedDocument = parseDocument(RESOURCES_DIR_PATH.resolve(location));
Document resultDocument = removeIgnoredCxmlNodes(parseDocument(resultCxmlPath));
assertXMLEqual(expectedDocument, resultDocument);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
には、XMLへの2つの文書を印刷することができますようにあなたは
DifferenceEvaluator
が、「属性フィルタ」を使用していないのでしょうか?明らかにXMLUnitは彼らが違うと感じています。これは真実かもしれませんが、それが許容できる場合は、以下に示すように@ DifferentialListenerを使用してください。 –