what is test driven development

Making sure that the source code functions are running and executing everything they are expected to is a really great challenge. The importance of that gets bigger every time a new library is built and depends on other functions. A basic function that fails can cause serious damage inside a complete firmware.

Test Driven Development (TDD) is a technique intended to make sure that the source code is correctly coded and tested in most of the possible use cases for it. The programmer will write the test code that calls the functions and check their behavior and return values with different input parameters. The objective is to add as many tests as required to let no unmapped scenario to fail.

The development process can be summarized in:

  1. Understand a new code requirement
  2. Code the a new test
  3. Make it compile
  4. Run the tests
  5. Check that it failed
  6. Implement the source code (just enough to make the test pass)
  7. Compile and run
  8. Check if the tests passed
  9. Repeat
Continue reading...

bugfree-robot project start

This post is the start of a new personal/educational project that motivated me to start this blog. It will be developed as kind of tutorial, guidance and general tips/tricks about coding for embedded systems using Test Driven Development (TDD) and some other techniques.

I’ve being coding microcontrolers for several years and it can be really challenging due to many reasons like:

  • define what it is supposed to execute
  • model the system’s architecture so it is able to run all its tasks
  • make sure it won’t fail while running…
  • it WILL fail sometime, so make sure that is is able to recover from failures (gracefully as they use to say)
  • check if all the functions are behaving correctly running by themselves and inside the full firmware
  • understand and control correctly the microcontroller peripherals and the other components on the hardware
  • be able to add features and change behaviors in the system and many times they will require big changes in the way other parts or it are planned and coded
  • (add here your own frustrations, there are many more on the road)
Continue reading...