When unit testing things that produce HTML output (such as some Grails taglibs) there are some common pitfalls. Comparing large chunks of markup with an expected string is very brittle; whitespace and attribute ordering becomes significant. Often people end up using regular expressions or assertions like
assert output.contains('<div id="foo">'). Whilst it may be a bit more maintainable this doesn’t really test correct DOM structure which is often important and again, attribute order can be a problem.
where: crew << ['Mal', 'Kaylee', 'Jayne'] nameLength = crew.length()