Test-Driven Development (TDD)
Test-driven development (TDD) is a proven software development process. It turns out that many more bugs get caught when tests are written alongside code.
“Testing shows the presence, not the absence of bugs” - Dijkstra
Some Testing Ideas / Topics
- Whitebox Testing
- Blackbox Testing
- Regression Testing
- Usability Testing (to be covered in CS447)
- Non-Functional Requirement
TDD Cycle
You first write failing tests before writing the program itself.
Steps
- Write the simplest possible test case (that the program doesn’t yet solve) → Test Fails
- Write the simplest possible program until the test passes. Some sub-steps for this in C++:
- Important step that is often overlooked: Refactor and tidy up code.
- Repeat until you have written passing test for all required functionalities
Benefits of TDD
- Reduce debugging effort
- Work incrementally. Stay focused on manageable tasks
- Always have a working version of the program. git restore
file.cpp
to roll back to the working version