本文介绍了XMLUnit是否有断言来忽略空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在一个测试中比较两个xml字符串,但是由于空白而导致测试不断失败.
I want to compare two xml strings in a test, but the test keeps failing due to whitespace.
@Test
public void testForEquality() throws Exception {
String myControlXML = "<msg><uuid>0x00435A8C</uuid></msg>";
String myTestXML = "<msg><uuid>0x00435A8C</uuid> </msg>";
assertXMLEqual(myControlXML, myTestXML);
Diff diff = new Diff(myControlXML, myTestXML);
assertTrue(diff.similar());
}
推荐答案
是的,XMLUnit可以忽略空格.有关详细信息,请参见 API文档.您可以通过设置启用它:
Yes, XMLUnit can ignore whitespaces. See API documentation for details. You can enable it by setting:
XMLUnit.setIgnoreWhitespace(true)
这篇关于XMLUnit是否有断言来忽略空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!