Unit Tests Ftw
So after spending a whole lot of (Very enriching!) time building a dynamic system to be able to control the drivers and run test with configurable parameters over the serial, I realized that that was just completely hopeless on such a tiny device as the Arduino. With no dynamic memory to speak of, trying to build a flexible dynamic system is just doomed to fail.
And then it hit me. I am trying to build testable code… and in extension a testable electro.mechanical system. There is a tool build for this: Auto testing. And that is one of my favourite software development tools of all time. And given that I don’t have access to a proper debugger, basically the only tool I have access to other than trial and error.
So yeah, I chucked out all of that nice flexible code and started writing my first unit tests. But they really won’t be unit tests, but integration tests. The challenge here is not to test the code per se, but the interaction between the code and the hardware. Checking things like if all wires are properly connected and that no components have broken is even more important than testing the code itself.
So the first unit test is a simple loop that starts the motors at a given power for a given time and checks that the encoders report that the motor has moved a reasonable distance. Because without that, nothing else will work.
So this is where I will be spending a lot of time now. One step at the time building up the core features, one test at the time. But then, that is the only way to properly develop software, isn’t it?