Gáspár Nagy on software

coach, trainer and bdd addict, creator of SpecFlow

TDD Anti-patterns

by Gáspár on December 4, 2008

I’ve just found this very good collection about TDD anti-patterns in James Carr’s blog and also some extensions (and prioritization) for it in stackoverflow. It’s much fun to read it and it is very useful.

Some of my favorites:

The Mockery – Sometimes mocking can be good, and handy. But sometimes developers can lose themselves and in their effort to mock out what isn’t being tested. In this case, a unit test contains so many mocks, stubs, and/or fakes that the system under test isn’t even being tested at all, instead data returned from mocks is what is being tested. (James Carr)

Now you see me, now you don’t — Children at play (Aaron Digulla)

The Nitpicker – A unit test which compares a complete output when it’s really only interested in small parts of it, so the test has to continually be kept in line with otherwise unimportant details. Endemic in web application testing. (Frank Carver)

The Peeping Tom – A test that, due to shared resources, can see the result data of another test, and may cause the test to fail even though the system under test is perfectly valid. This has been seen commonly in fitnesse, where the use of static member variables to hold collections aren’t properly cleaned after test execution, often popping up unexpectedly in other test runs. Also known as The Uninvited Guests (James Carr)

Second Class Citizens – test code isn’t as well refactored as production code, containing a lot of duplicated code, making it hard to maintain tests. (Ilja Preuß)

Comments are closed.