Tuesday, January 30, 2007

Simple assertEquals in xml

While things like XmlUnit probably work well for complex xml differences, if you just need to compare two similar xml fragments then striping the whitespace from them and compare is easy in java (or any other language with regex).

Just do: myString.replaceAll("\\s*", "") on both the expected and actual result.

No comments: