TDD - A Reminder of the Principles
- 4. THE CYCLE OF TDD
Red - Green - Refactor
Red: create a failing test
Green: make the test pass
Refactor: make the code maintainable
- 5. STRUCTURE OF A UNIT TEST
Arrange - Act - Assert
Arrange: prepare some data
Act: call some method
Assert: verify the result
- 6. ADVANTAGES OF TDD
The code you write is correct (provable, automated)
The code you write is all the code you need
You can safely refactor the code
- 7. HEURISTICS FOR TDD
If you don't know what to do anymore
Think of the simplest thing to test
Think of the simplest way to make the test pass
Think of edge cases (but not for too long)
Think of how you would like to be able to use the object