Comparing two XML strings/files in Groovy/Java

后端 未结 3 1245
执念已碎
执念已碎 2020-12-31 15:36

I\'m writing unit tests for checking some XML builder.

Now I\'m running into the problem of syntactical differences between the expected result and the actual result

3条回答
  •  Happy的楠姐
    2020-12-31 15:49

    You can use the Groovy XMLUnit utility like this:

    XMLUnit.setIgnoreWhitespace(true)
    XMLUnit.setIgnoreComments(true)
    XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true)
    XMLUnit.setNormalizeWhitespace(true)
    
    XMLUnit.compareXML(expectedXml, actualXml)
    

    To compare XML files while ignoring the syntactical differences.

提交回复
热议问题