One of the reason I like doing test driven development is the really short feedback loop it offers (there are many others, but this post is about the feedback loop). Basic idea is:
- Write a test that demonstrates the lack of the wanted feature
- Start developing
While developing (Repeat until acceptance test is passed):
- Write failing unit test
- Make the test pass
All the time, you keep running all the tests that have been written before. This gives confidence that nothing is accidentally broken while the new stuff is being developed and code is being refactored. As soon as the acceptance test passes, feature is ready. Of course it might lack some detail that the acceptance test doesn’t cover, but for those you can always write more acceptance tests.
This is really nifty and I like doing it. While working with .Net code, cycle is like this (in more detailed level):
- Write test, compile, run tests
- Code to make the test pass, compile, run tests
- Refactor, compile, run tests
While working with Python, cycle gets shorter:
- Write test, run tests
- Code to make the test pass, run tests
- Refactor, run tests
This morning while biking to work, I had an idea that it would be really cool if the test suite at the local workstation would work in a similar way to test suite in the continuous integration.
I’m of course not the first one to think this. Two first hits were autonose and nosy. I tried autonose first, but couldn’t get it to install because of mismatch in md5 hash. With nosy I was more lucky and got it installed and quickly set up. I still need to manually start it by simply typing:
In my top level source folder and system starts itself and runs all the tests found inside the folder hierarchy. After that, everytime a source file is changed tests are automatically run. For fully automated solution on Linux, there’s nosier.
After this, cycle is shortened even more:
- Write test
- Make test pass
For .Net side, there is of course equivalent tools. First one I found is called NCrunch and looks quite promising. I haven’t tested that, but I probably should.