11
Test-Driven Development Let the tests be your guide

Tdd let the tests be your guide.pptx

Embed Size (px)

DESCRIPTION

How TDD is done

Citation preview

Page 1: Tdd   let the tests be your guide.pptx

Test-Driven Development Let the tests be your guide

Page 2: Tdd   let the tests be your guide.pptx

It starts with the test

Page 3: Tdd   let the tests be your guide.pptx

Benefits of TDD ¡ All the benefits of unit testing plus … ¡  It becomes hard to create errors in the first place ¡  You almost have to try to create errors

¡  Better matches the business requirements ¡  It does what it is supposed to do ¡  It must because we only write tests that satisfy

requirements ¡  Encourages communication with the business ¡  It eliminates gold plating

Page 4: Tdd   let the tests be your guide.pptx

Red, green,

refactor ¡  asdf

Page 5: Tdd   let the tests be your guide.pptx

The red phase

Page 6: Tdd   let the tests be your guide.pptx

You want to write positive tests and negative tests ¡ Negative tests involve values that are outside

acceptable ranges. ¡  They should fail ¡  You're testing to make sure that they do

¡  Positive tests are ones that should pass

Page 7: Tdd   let the tests be your guide.pptx

The green phase

Page 8: Tdd   let the tests be your guide.pptx

The refactoring phase

Page 9: Tdd   let the tests be your guide.pptx

Once finished you pick up a user story and start again writing a new failing test

Page 10: Tdd   let the tests be your guide.pptx

Refactoring example

Page 11: Tdd   let the tests be your guide.pptx

Summary ¡  Unit testing is the cornerstone of TDD ¡  TDD = Red, green, refactor ¡  Red = write a failing unit test ¡ Green = make the unit test pass using a naïve

implementation ¡  Refactor = improve the code quality ¡  TDD results in huge benefits like better quality

code that better matches the business requirements, encourages communication and eliminates gold plating