What is TDD?

Short, iterative cycle: Red-Green-Refactor

  • Write test
  • Watch it fail (red)
  • Make it pass (green)
  • Make it better (refactor)
  • Repeat

Why TDD?

  • Get home on time!
  • More confidence
  • Take smaller, more manageable steps
  • Catch defects earlier in the process
  • Create smaller, more focused classes

Demo: FizzBuzz


For numbers 1..100 print the number, unless


  • divisible by 3, print "fizz"
  • divisible by 5, print "buzz"
  • divisible by both, print "fizzbuzz"

Common Questions

  • What to test?
  • How: private methods?
  • How: methods that return void?
  • Can you overtest?
  • Should you depend on the order of tests?

Tools & More Topics

  • Java
  • JUnit
  • IntelliJ
  • Gradle
  • Theories
  • Mocking
  • BDD
  • Test Pyramid
  • Builders & Test Data Management

Feedback? Help?

bbiglari@thoughtworks.com

twitter: @sghill
sghill@thoughtworks.com