The AVR assembly language unit tests that I spoke of last week are going well. I decided to explore the idea of unit testing by writing tests for the easier to test aspects of the serial protocol code and then, as this went well, I decided to write tests for the serial protocol code in order rather that simply jumping to write tests for the code that I know is broken. I figure that I’m more likely to write the tests that I actually need (i.e. for all of the code) this way, rather than simply writing the tests that I think I need.
So far this is going well. The test harness program is now considerably bigger than the real servo controller program. I have around 50 tests at present and I’m around half way through the serial protocol code. I’ve found a couple of otherwise hard to find bugs; which is good. As usual the tests act as documentation for how the code is used and what the inputs and outputs and side effects are. This doesn’t remove the need for actual documentation but it helps.