+ All Categories
Home > Documents > Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers...

Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers...

Date post: 26-Sep-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
58
Michael Feathers Steve Freeman Ten Years of Test-Driven Development © http://www.flickr.com/people/29278394@N00/
Transcript
Page 1: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Michael FeathersSteve Freeman

Ten Years of Test-Driven Development

© http://www.flickr.com/people/29278394@N00/

Page 2: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Review: TDD in one slide

Page 3: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Review: Acceptance Test-Driven

Page 4: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Review: The larger feedback loop

Page 5: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

1960’s

Page 6: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

The secrets of the ancients

http://www.flickr.com/photos/mckaysavage/3227695797/

Page 7: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

It was just assumed that any pro would do a damn good job of this activity, not to be embarrassed by unit bugs found in integration test or system test—or god help us, in production.

Jerry Weinberghttp://secretsofconsulting.blogspot.com/2008/12/how-we-used-to-do-unit-testing.html

Page 8: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Professionals test their code

Page 9: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

1970’s

Page 10: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Kent Beck reads his Dad’s books

http://www.flickr.com/photos/mwichary/2376639066/

Page 11: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

i thought, what a stupid idea. i want tests that pass, not tests that fail. why would i write a test when i was sure it would fail. well, i'm in the habit of trying stupid things out just to see what happens, so i tried it and it worked great.

i was finally able to separate logical from physical design. i'd always been told to do that but no one ever explained how.

it said the way to program is to look at the input tape and manually type in the output tape you expect. then you program until the actual and expected tapes match.

Page 12: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Separate what from how

Page 13: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

1989

Page 14: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Ward short-circuits the process

Page 15: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

I decided to short-circuit the process by reading his spreadsheets into a test framework I wrote in a day. […] we sailed through a big five audit when the auditor admitted that he'd never seen anything like our test browser and passed us before lunch.

Page 16: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Automated tests confirm features

Page 17: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

1996

Page 18: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Scaling up on the C3 project

Page 19: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Ron remembers

We had lots of unit tests on C3. We agree that we didn't START with TDD, though we had been told tests first was good.My personal [recollection] is that I didn't really get into it until Kent's book started to come out.

Page 20: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

It’s a change in culture

Page 21: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

XUnit

JUnit

SUnit

Page 22: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Spreading the word

…open discussions on C2 wiki

codified in books

Page 23: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

This isn’t music

Page 24: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

“Working” isn’t good enough

Page 25: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

1999

Page 26: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

The origins of Mock Objects

•“These getters we write for testing are cluttering up the design”

•Difficulties with integration testing•Endless discussion at the

eXtreme Tuesday Club

Page 27: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Mock Objects

Page 28: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

What Connextra learned

•Composition over inheritance (again)•Roles based on behaviour

public class Person { public void printDetails(PrintWriter writer) { writer.println(name); writer.println(age); writer.println(telephone); }

public class Person { public void handleDetails(PersonHandler handler) { handler.name(name); handler.age(age); handler.telephone(telephone); }

Page 29: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Listen tothe tests

Page 30: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

2001

Page 31: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Continuous Build

Page 32: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Safety Culture

Increasing safety

Accident impact

Accidentsreported

(Thanks to Keith Braithwaite for the concept)

Page 33: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

A working system provides feedback

Page 34: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Chris Stevenson’s TestDox style

public class SheepTest { @Test public void eatsGrass() { … } @Test public void bleatsWhenFrightened() { … } @Test public void producesDeliciousMilk() { … } @Test public void movesAwayFromSheepdogs() { … }}

A Sheep eats grassA Sheep bleats when frightenedA Sheep produces delicious milkA Sheep moves away from sheep dogs

Page 35: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Focus on intent

Page 36: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

2002

Page 37: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Kent Beck scales down

•Write a failing automated test before you write any code

•Remove duplication

Page 38: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

When you’re lost,slow down

Page 39: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

2003

Page 40: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

The next generation

Page 41: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

2004

Page 42: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

TDD for the Customer

Page 43: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Confirm understanding with examples

Page 44: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Living in the Real World

Page 45: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Legacy code is code without tests

Page 46: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Rails. TDD inside

Page 47: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

RSpec “No testing here…”

module Mastermind describe Game do context "starting up" do it "should send a welcome message" do messenger.should_receive(:puts).with( "Welcome to Mastermind!") game.start end end end end

Page 48: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

It’s not only about testing

Page 49: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

and another generation...

Page 50: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

2007

Page 51: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

• More effort, better quality

• Effects more visible on real projects

• Very hard to get meaningful results

• Some dissent about the results

The research suggests…

Page 52: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Poor-man’s Formal Methods

Page 53: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Project Slope Automated Unit TestsJasml 0.1 0.95Sunflow 0.06.3 1.59m-e-c scehdule α3-10 1.69NanoXML 2.2.1 1.77Syncbuilder1999 1.84Itext 1.4.8 1.88Xcool 0.1 1.93Ant 1.7.0 2.25 ✔

Jfreechart 1.0.3 2.30 ✔

MarsProject 2.79 2.33 ✔

Log4j 1.2.14 2.43 ✔

JUnit 3.8.1 2.49 ✔

JMock 1.1.0 2.79 ✔

Spring 2.0.1 2.78 ✔

Measuring TDD

http://www.keithbraithwaite.demon.co.uk/professional/software/index.html

Page 54: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Understand the principles behind the practices

Page 55: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Professionals test their codeSeparate what from howAutomatic tests confirm featuresIt’s a change in culture“Working” isn’t good enoughListen to the tests

A working systemprovides feedbackFocus on intentWhen you’re lost, slow downIt’s not only about testingLegacy code is code without testsUnderstand the principles behind the practices

Page 56: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

ExpressivenessFeedback

Professionalism

Page 57: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman

Thanks to...

Kent Beck

Keith Braithwaite

Chet Hendrickson

Ron Jeffries

J.B. Rainsberger

Tim Mackinnon

Dan North

Nat Pryce

Chris Stevenson

youDevise.com

Page 58: Ten years of TDD - qconlondon.com€¦ · Ten-Years of Test-Driven Development. Michael Feathers and Steve Freeman i thought, what a stupid idea. i want tests that pass, not tests

Michael FeathersSteve Freeman

Ten Years of Test-Driven Development

© http://www.flickr.com/people/29278394@N00/


Recommended