SlideShare a Scribd company logo
TDD
A reminder of the principles
Matthias Noback
@matthiasnoback
APPLICATION PROGRAMMING
INTERFACE (API)
How you can work with an object
Create
Modify
Inspect
TEST-DRIVEN DEVELOPMENT (TDD)
Specify the API (D = Design?)
Implement it
Prove its correctness
THE CYCLE OF TDD
Red - Green - Refactor
Red: create a failing test
Green: make the test pass
Refactor: make the code maintainable
STRUCTURE OF A UNIT TEST
Arrange - Act - Assert
Arrange: prepare some data
Act: call some method
Assert: verify the result
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
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
KATA
A short programming/TDD exercise
MARS ROVER KATA
0
10
10
2,3
N
frbbrfl
GO!
Work together if you like
Share what you've got
HOW TO SET UP A PROJECT?
And run unit tests?

More Related Content

TDD - A Reminder of the Principles