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.
title: TDD Mantra Don’t write any production code unless you have a failing test.
“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
You first write failing tests before writing the program itself.
- 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.cppto roll back to the working version