
Unit Testing - Do Repeat Yourself - blazzerbg
http://codebetter.com/blogs/karlseguin/archive/2009/09/12/unit-testing-do-repeat-yourself.aspx
======
gruseom
I've noticed this many times, or something like it, so I also have a higher
tolerance for duplication in tests than in production code. The reason is that
ideally unit tests are orthogonal, self-contained little stories about the
system: "when you do this, then that, X happens". There is usually a lot of
overlap between the "this" and "that" addressed by different tests; indeed
there had better be, or simple combinatorics suggest you're missing cases.
When you try to generalize all of this to eliminate the duplication, you end
up with complex, abstract code that may be shorter overall but has lost the
all-important property of being able to read a given test easily and
understand what it is saying about the system.

I just remembered I wrote about this before:
<http://news.ycombinator.com/item?id=239167> (searchyc ftw).

