test drivendevelopment onstage demo

32
Test Driven Development An On-stage Demonstration @LlewellynFalco

Upload: llewellyn-falco

Post on 11-May-2015

266 views

Category:

Technology


1 download

DESCRIPTION

Test-driven development (TDD) is a skill that takes patience to master—you can’t learn it reading a book. As with learning any new language, to gain fluency you need to practice TDD with competent coaching and lots of hard work. Many well-intentioned programmers try and finally give up on TDD because they never develop the fluency it requires. On stage, Llewellyn Falco leads a live TDD demonstration, talking through the process and microsteps of: (1) studying a feature, (2) creating an initial test, and (3) iteratively developing the related test code and feature code until the feature is completely programmed. Watch how to iteratively write a test, see it fail, and then write the feature code to make it pass. After explaining the theory behind the particular TDD technique used, Llewellyn leads participants in testing progressively more complex objects and scenarios.

TRANSCRIPT

Page 1: Test drivendevelopment   onstage demo

Test Driven DevelopmentAn On-stage Demonstration @LlewellynFalco

Page 2: Test drivendevelopment   onstage demo

HISTORY…A little

Page 3: Test drivendevelopment   onstage demo
Page 4: Test drivendevelopment   onstage demo
Page 5: Test drivendevelopment   onstage demo
Page 6: Test drivendevelopment   onstage demo

Is Testing Faster? (Test After)

Work (code)

Non-Work(tests)

60 Minutes

X minutes

Code60 Minutes< Code + Test

60 + X minutes

Page 7: Test drivendevelopment   onstage demo

Is Testing Faster? (Test 1st)

Work (code)

Non-Work(tests)

30 Minutes

X minutes

Code60 Minutes < Test + Code

X + 30 minutes?

60 – Time Saved

Page 8: Test drivendevelopment   onstage demo

Today’s Kata: Triangle1) A side has a distance2) Side knows endpoints3) 3 points4) 3 sides5) Perimeter6) Get sides touching a point7) Get side opposite a point8) The angle of 2 sides touching a point9) 3 angles10) Right Triangle

Page 9: Test drivendevelopment   onstage demo
Page 10: Test drivendevelopment   onstage demo

Parts of a Test

1) Do2) Verify

Page 11: Test drivendevelopment   onstage demo

Demo

Page 12: Test drivendevelopment   onstage demo

Benefits of Unit Tests

1) Specification2) Feedback3) Regression4) Granularity

Page 13: Test drivendevelopment   onstage demo

Regression

If I used to get : Then I still get :

AA

Page 14: Test drivendevelopment   onstage demo

Intentional Code

// Create a Side from (0,0) to (5,0)

var side = new Side(0,0,5,0);

Page 15: Test drivendevelopment   onstage demo

7H15 M3554G3 53RV35 7O PR0V3

H0W 0UR M1ND5 C4N D0 4M4Z1NG 7H1NG5! 1MPR3551V3 7H1NG5!

1N 7H3 B3G1NN1NG 17 WA5 H4RD BU7 N0W, 0N 7H15 LIN3

Y0UR M1ND 1S R34D1NG 17 4U70M471C4LLY W17H 0U7 3V3N

7H1NK1NG 4B0U7 17, B3 PROUD! 0NLY C3R741N P30PL3 C4N

R3AD 7H15. U C4N R35D 7H15!!!

Page 16: Test drivendevelopment   onstage demo

Consume 1st

Write the objects & methods you wish existed

Page 17: Test drivendevelopment   onstage demo

Test Until Bored

Test the cases that bring you value

Page 18: Test drivendevelopment   onstage demo

VerificationIs it the right answer?1. Change the Question2. Ask an expert

Page 19: Test drivendevelopment   onstage demo

Completing the CircleYour output should tell the story.Objects should have ToStrings

Benefits1. Specification2. Feedback3. Regression4. Granularity

Page 20: Test drivendevelopment   onstage demo

Fake it Till You Make ItBuys some timeAllows for Triangulation

Page 21: Test drivendevelopment   onstage demo

Today’s Kata: Triangle1) A side has a distance2) Side knows endpoints3) 3 points4) 3 sides5) Perimeter6) Get sides touching a point7) Get side opposite a point8) The angle of 2 sides touching a point9) 3 angles10) Right Triangle

Page 22: Test drivendevelopment   onstage demo

Verifying MultiplesVerify Single:Approvals.Verify(result);

Verify Many:Approvals.VerifyAll(results, "label");

Page 23: Test drivendevelopment   onstage demo

Multiple Cases

Approvals.VerifyAll(cases, c => TestWith(c));

Page 24: Test drivendevelopment   onstage demo

Maintaining TestsSame Quality as Production Code

Page 25: Test drivendevelopment   onstage demo

Granularity of Test?

Page 26: Test drivendevelopment   onstage demo
Page 27: Test drivendevelopment   onstage demo

ResourcesTest Driven Development: By Example

Kent Beck

Page 28: Test drivendevelopment   onstage demo

Resources www.ApprovalTests.com(.net, java, php, ruby)

Herding Code Podcast

Page 29: Test drivendevelopment   onstage demo

Resourceswww.ApprovalTests.com

(.net, java, php, ruby)

20 episode youtube series

Page 30: Test drivendevelopment   onstage demo

Resources

Intro To TDD Class (4 Day)Legacy Code

www.Develop.com

Page 31: Test drivendevelopment   onstage demo

TeachingKidsProgramming.orgDo a Recipe Teach a Kid (Ages 10 ++)Microsoft SmallBasic, Java Free Courseware (recipes)

Page 32: Test drivendevelopment   onstage demo

Please fill out evaluations:TDD – Demo #AW11

@LlewellynFalcohttp://LlewellynFalco.Blogspot.comhttp://www.approvaltests.com