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
The question and the accepted answer (as of today) correspond to a legacy version of XMLUnit.
For those interested in knowing how to do it with XMLUnit v2 on Groovy:
def "XMLs must be identical"() {
setup:
def control = ' '
def test = '''
'''
when:
Diff d = DiffBuilder.compare(Input.fromString(control))
.withTest(Input.fromString(test))
.ignoreWhitespace()
.ignoreComments()
.normalizeWhitespace()
.build()
then:
!d.hasDifferences()
}
Perhaps there is a "groovier" way of doing it but I think it's OK for illustration purposes :)