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:
- Understand a new code requirement
- Code the a new test
- Make it compile
- Run the tests
- Check that it failed
- Implement the source code (just enough to make the test pass)
- Compile and run
- Check if the tests passed