I’ve seen the light. For so long I thought I was doing TDD, I thought I was being agile, and I hate to admit it, but I wasn’t. I was trying too hard. I was thinking too much, and secretly holding to fears and misconceptions that were stopping me from realising the benefits of some of the best agile practices.
I’m not hung up or bummed out though – it was fair enough really – the project’s I was on didn’t really allow for a truly agile approach for the majority of the time. The fact is you have to breathe out before you breathe in, and I was in a situation where there was no breathing space at all.
But I eventually did get some breathing space, and a neat reading list and as fate would have it, that coincided with one of those periods that we all get as software engineers, where you get real hungry. I’m not talking raid the fridge hungry, I’m talking knowledge hunger – process hunger, efficiency hunger.
I’ve been lapping up some great stuff and it made me see where I was going wrong in a lot of areas. The biggest one I came to realise was that I wasn’t really doing TDD.
I kept trying, but I’d always buy into THE OLD LIE. You know – “it takes too long to write the test up front, I’ll just nip back later”. Recently though, I sat myself down after my latest book bout and had a word with myself.. what was stopping me from doing this?
It turns out it was actually something quite simple – it took so long for me to compile and run tests on the projects that I was in, that I had a skewed opinion of TDD. I was literally associating the amount of time it took to build and run a full testrunner (often times in excess of 800 tests) with TDD. In short I had been foolish.
I think it was the nazareen who said “if thy eye offends thee, tear it out”, which though seemingly grim, is actually good advice. And tear it out I did.
I basically came to a new understanding – this is it: The testrunner is the total suite of tests for the entire application, The testrunner is the docuemntation of the API’s of the entire application, The testrunner is ueful for regression, The testrunner is useful when building to ensure the application is in a healthy state, The testrunner actually is more and more depending on how many books you read, and how good your memory is.
One thing the testrunner is NOT however, is a harness for doing TDD.
This has been my single biggest leap in understanding of TDD. Quite simply the apps I work on are so big that building and running the entire testrunner in order to do TDD is simply unbearable.
On my last project some of us would sometimes remove all the tests from the testsuite, save 1 or 2 (remember, if thy eye offends thee – tear it out ;-) ). However, we never formalised this process – sometimes with disastourous consequences: You’d run the testrunner and find someone had deleted ALL of the tests in the app.. Looks like that build that went out might have only gone out with 1 out of 1,000 tests being run on it..
I can’t believe how obvious the answer is.. I just made a new rig – TDDRunner.mxml, and a new testsuite AllTDDTests.as. It’s really simple – each developer has their own AllTDDTests file which they keep the tests in that they need at any given time, and never check it in.
I’ve been doing this for a week now and with great results. I’m genuinely able to do TDD without any painful overhead, waiting for the compiler, or other tests, or risking deleting the testuites, or without even losing concentration. It’s a dream come true.
As I write the tests, I add them to the main testrunner, and I run this whenver I reach a mile stone (such as finishing a presentation model, or a domain model ) to ensure that regression is not caused elsehwere.
I cannot emphasize enough how great the benefits of this approach are. Myself and a couple of colleauges are literally buzzing off TDD as a result of this. It’s also much easier to sell to others who are usually closed to it.
It’s gone from barely being able to justify it to some colleagues to the point where they now have no excuse for not doing it.
Perhaps with other languages this isn’t such a problem, but with actionscript, or I suspect with any app with a large testsuite, I suspect this simple process improvement will lead to more developers practising TDD.

RSS Feed