tdd introduction with kata fizzbuzz

Post on 29-Jan-2018

254 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

An Introduction to TDDBy Example

Test Driven Development• Rapid feedback

• Short development cycles

• Incremental design

• Reduced complexity

• Force you to think

• Confidence

Write a Failing

Test

Make the Test

Pass

Refactor

TDD

Red Green Refactor

Principles1. Don’t write any new code until you first have a

failing test.

2. Test everything that could “possibly” break.

3. BabySteps

How to Get to Green• Fake it till you make it

• Fake it - return what the test requires, nothing more

• Obvious - when the code to make the test pass is trivial

• Triangulation - write a second test forcing the ‘fake’ solution to be exposed as insufficient

Refactoring• DRY - Don’t Repeat Yourself

• Technical Debt

• Don’t Live with Broken Windows

• Refactor Early, Refactor Often

Refactoring• Rename variable/method

• Extract variable/method

• Inline variable

The Rules of FizzBuzz• If number is divisible by 3, return “Fizz”

• If number is divisible by 5, return “Buzz”

• If number is divisible by 3 & 5, return “FizzBuzz”

• Otherwise, return the number

Let’s Develop FizzBuzz Kata

Further Reading

Further Reading

Further Reading

top related