Wednesday, August 19, 2009

Unit Tests Are Not About Testing

See Unit Tests Are Not About Testing at its new home on bradley-holt.com.

I had the suspicion for a while but it didn't become clear to me until recently that unit testing really is not about testing. Sure, you are writing tests and there is certainly value in having "tests." However, the real value of unit testing becomes evident when you stop thinking of it in terms of testing. If it's not about testing then what is it about? Unit testing is really about defining behavior. Enter Behavior Driven Development (BDD):

It is not too surprising that it takes apprentice TDD [test-driven development] practitioners a while to realize that TDD is not about testing when all of the nomenclature surrounding it is described in terms of testing.

The aim of Behaviour Driven Development (BDD) is to address this shortcoming. By using terminology focused on the behavioural aspects of the system rather than testing, BDD attempts to help direct developers towards a focus on the real value to be found in TDD at its most successful.

If you're using PHPUnit then check out the Behaviour-Driven Development chapter for more details on how you can use this approach.

No comments: