CodeRetreat

With Draven & Judge

Test-Driven Development

A goal is Clean Code!

  1. Don’t write a line of new code unless you first have a failing automated test

  2. Eliminate duplication

Two rules of TDD

by Kent Beck

  1. Write a test…

  2. Make it run…

  3. Make it right…

A goal is loose coupling!

  1. You are not allowed to write any production code unless it is to make a failing unit test pass.

  2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.

  3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

Three rules of TDD

by Uncle Bob Martin

A goal is documenting!

  1. Write a test for the next bit of functionality you want to add

  2. Write the functional code until the test passes

  3. Refactor both new and old code to make it well structured

Three rules of TDD

by Martin Fowler

A goal is easy refactoring!

About TDD

by James Shore

A goal is fast cycles via small steps!

Coding Rules for Today

  • Strictly follow TDD rules and do fast cycles

  • Don't forget refactoring

  • As delivery doesn't matter, focus on readable Clean Code

  • Test names and bodies must document the implementation

THX

Some advice

Documenting

  • Test naming

    • Include the method under testing

    • Add context, preconditions

    • Write what will happen, the expected behaviour

  • Test cases against behaviour