How I discovered the magic of software testing

Written by Rasmus Rønn Nielsen, 2011-11-11

When I was introduced to software testing I knew I had to try it out. I started by carefully mimicking what I've seen others do in some simple unit tests.

When my tests became more complex I got frustrated. I often spend much longer writing the test, than the subject code. Consequently, I became more reluctant to writing tests.

Despite my testing aversion, I painfully kept on writing tests every now and then.

And then something magical appeared. Gradually, the effort needed to write a good test fell, and the joy obtained from doing it rose. My test writing skills improved. It felt good, and it encouraged me to write even more tests.

Looking back, I realize that I had subconsciously assumed that writing tests was easy. Test code looked simple and the idea of setting up a context and then matching expected against actual seemed trivial. Piece a cake!

This lead me to blame the entire test methodology when struggling with a test. What a fool I am!

Today, I almost never write any code before writing a test for it first. Besides ensuring quality it helps me to come up with better designs and make refactorings much more pleasant.

So, if you have not yet felt the magic of testing, I encourage you to start by accepting that writing and designing good tests is a skill to be learned. Then start testing well aware that you will go through a painful learning process before feeling the magic.

Believe me, it's well worth it! :)