The Red-Hat Green-Hat game

I think the modern equivalent of 40,000 page specifications is lots of test cases that demonstrate what the software should do; document requirements through test code.

There’s an interesting part in the article where the software team is divided into two teams: -coders who write the code testers who try and break the code

And there’s a healthy competition between the two. If the test cases are written in software this could amount to one team of people writing test cases to try break the code and another team trying to write bullet proof code to get past the test cases.I think both teams could learn alot from each other.

In particular the testers should really be developers who know how to develop unit and integration testing software. Far too often in the software world testing teams are viewed as people who ‘push buttons’ rather than people who develop test cases to automatically test software.

I wonder if it’d help if software teams took turns being in both camps? Say 2 weeks a month they spend purely writing test cases to try break a part of the system, the next 2 weeks they spend writing code on another part of the system to try get past the test cases put in place by the other team. This could lead to some healhy competition.

-James Strachan

This is a really effective way of writing development systems which I frequently put in place in teams on a much smaller level using pair-programming. However I use it for writing finer grained unit-tests rather than acceptance tests.

Rules

Get two developers in front of the same machine and give one of them a red hat to wear and another a green hat.

Mr Red’s role is to write a small unit-test that fails, and in doing so, clearly expresses the proposed interface and intention of the new code. As soon as he’s happy with his failing test, he slides the keyboard over to Mrs Green.

Mrs Green’s intention is to do just enough work to make the test pass, at which point the keyboard is passed back over to Mr Red.

Repeat cycle.

This red/green cycle typically takes anywhere between one and ten minutes before they keyboard is passed back to Mr Red. Every so often (a few times a day) the developers switch hats.

The competition is fierce. Mr Red defines the best possible API as possible and the most evil tests. Mrs Green solves the problem set by Mr Red in the most elegant way she can.

Benefits

The great thing about this is that it’s so easy to get started with. Oh, and you don’t actually need hats (but they’ll make you feel cool).