Yup, that's where the value is

Mats writes about how he finally got unit testing by realising that the value comes not when all your tests pass and you feel happy but when one of your tests fails and you feel sad…

This is actually something I’m not sure I’d quite realised for myself. I’m pretty good now; I know why I should write tests, I know that I feel more comfortable making changes when I have tests to support me, but I never really accepted that having all the tests passing doesn’t really buy you much.

It’s when a test fails that you win.

Tests that pass just tell you that your tests pass. The code may still contain bugs, your tests may still miss key portions of your code, it may just all be hype and fluff and nonsense.

When a test fails you know you’ve broken something. You’ve changed a rule. Something you thought was true is no longer true. So, your test was wrong or your change is wrong; either way you need to think about what you just did. This is the good part. This is the point.

Thanks Mats.