Test Driven Development (TDD) follows three main laws: only write production code to pass a failing test, only write enough test code to fail, and only write enough production code to pass the test. TDD brings benefits like improved debugging, courage to refactor, documentation, and design. Good unit tests are atomic, isolated, repeatable, revealing, and fast. The structure of a test is to arrange inputs, act on the system under test, and assert the expected outcomes. Strategies for TDD include using obvious implementations, faking dependencies, and triangulating tests. Practicing TDD involves code katas, communities, and conferences.
1 of 15
Download to read offline
More Related Content
Intro TDD Portuguese developers meetup London 16/04/2014
4. Laws
You are not allowed to write any production code
unless it is to make a failing unit test pass.
You are not allowed to write any more of a unit
test than is suf鍖cient to fail; and compilation
failures are failures.
You are not allowed to write any more production
code than is suf鍖cient to pass the one failing unit
test.
6. Qualities of a Good Unit Test
Atomic
Isolated
Repeatable
Revealing
Easy to Setup
Fast
7. Inside a test
Arrange all necessary preconditions and
inputs
Act on the object or method under test
Assert that the expected results have occurred
Assert First?