TDD and Getting Paid

41
u f Test Driven Development and Getting Paid! Rowan Merewood Software Eng. / Team Lead Ibuildings

description

Test-driven development is generally regarded as a good move: it should result in simple decoupled design, your tests tend to cover behaviour not methods, and far fewer bugs. However, just getting unit tests in on a real, commercial project is hard - switching to TDD is even harder. Often you can start a project with good intentions and coverage, then the deadline looms and the tests go out then the hacks come in. So, instead of beating ourselves up about not being perfect let's look at an interative approach to adopting TDD principles. We'll look at tactics for selling TDD to your client, boss and colleagues. This talk will also cover methods for making TDD easier for you by showing you what tools you can use to integrate it into your development environment. In the project itself, we'll examine how we can make small but permanent steps towards full TDD, without losing that progress when deadlines hit. We'll also cover a few methods for learning on your own time and how the whole process can actually be made quite enjoyable.

Transcript of TDD and Getting Paid

Page 1: TDD and Getting Paid

uf

Test DrivenDevelopment

andGetting Paid

!

Rowan MerewoodSoftware Eng. / Team Lead

Ibuildings

Page 2: TDD and Getting Paid

m

WHO AM I?

Software Engineer &Technical Team Leadat Ibuildings UK

I want to write good codeand earn a living

@rowan_m

Page 3: TDD and Getting Paid

WHO AM I?Not ?

si-am-not-a

Cconsultant

well-maybe-a-little

Page 4: TDD and Getting Paid

s

WHO AM I?Not ?

i-am-not

selling-a

book

Page 5: TDD and Getting Paid

s

WHO AM I?Not ?

i-am-not

a-slave-to

one=method

Page 6: TDD and Getting Paid

@THE GOOD

Clean code, smart devsLatest technology

Building your career

Elitist / Intimidating?

DIFFERENT SITUATIONS

Page 7: TDD and Getting Paid

gTHE BAD

Disgusting codeDevs don't careCareer dead-end

Changes break the app.Always bug-fixing

DIFFERENT SITUATIONS

Page 8: TDD and Getting Paid

cTHE UGLY

Good tests are hardWriting tests takes time

Time is money

You're not an expert(yet...)

DIFFERENT SITUATIONS

Page 9: TDD and Getting Paid

WHAT IS TDD?

1.Decide what you want to do2.Write a test to show it working3.Run the test and watch it fail4.Write just enough code to pass the test5.Re-run the test (and test suite)6.Refactor (refine/improve)7.Re-run tests8.Repeat

Page 10: TDD and Getting Paid

WHAT IS TDD?

RED

GREEN

REFACTORHsimplify

Page 11: TDD and Getting Paid

lWHY IS THIS HARD?

Do you know whatyou want

before

you code it?

Page 12: TDD and Getting Paid

lWHY IS THIS HARD?

Does your clientknow whatthey want?

Ever?

Page 13: TDD and Getting Paid

Train yourself to think like a scientist

1.Hypothesis2.Repeatable Experiment3.Conclusions ]

Page 14: TDD and Getting Paid

Train yourself to think like a scientist

1.Hypothesis2.Repeatable Experiment3.Conclusions ]

ninja

Ninja weapon

Kata( 型 or 形 , literally: "form")

A set of movements

you repeat again and again

until can do it perfectly.

Page 15: TDD and Getting Paid

!DAVE THOMAS

co-author ofThe PragmaticProgrammer

Code Katahttp://codekata.pragprog.com/

Page 16: TDD and Getting Paid

ROY OSHEROVE - TDD Katahttp://osherove.com/tdd-kata-1/

Create a simple String calculatorwith a method int Add(string numbers)

The method can take 0, 1 or 2 numbers,and will return their sum

(for an empty string it will return 0)for example “” or “1” or “1,2”

Page 17: TDD and Getting Paid

.ROY OSHEROVE - TDD Kata

demo

Page 18: TDD and Getting Paid

Now you're an expert...

Do not assume you canjust start to do thisin your project

warning

D

Page 19: TDD and Getting Paid

DDON'T BE A HERO

Introduce tests all at once...

● You will miss your deadline● Your tests will not be maintained● Your team will hate you

Page 20: TDD and Getting Paid

LDIFFERENT APPROACHES

Force testson your client

Make your clientwant the tests

Page 21: TDD and Getting Paid

LFORCING TESTS

Add a fixed percentageto your estimates.

Do not compromiseyour principles.

Page 22: TDD and Getting Paid

LSELLING TESTS

Use tests to define 'done'.

Involve the clientin creating tests.

Make the testsa deliverable.

Page 23: TDD and Getting Paid

LSELLING TESTS

Use tests to define 'done'.

Involve the clientin creating tests.

Make the testsa deliverable.

Fitnesse Frameworkhttp://fitnesse.org/

Page 24: TDD and Getting Paid

LSELLING TESTS

Use tests to define 'done'.

Involve the clientin creating tests.

Make the testsa deliverable.

Seleniumhttp://seleniumhq.org/

Fitnesse Frameworkhttp://fitnesse.org/

Page 25: TDD and Getting Paid

DDON'T BELIEVE THE HYPE

Make sure you don't over-promise.

Make sure you have theinfrastructure and skills

NO SILVER BULLETS

Page 26: TDD and Getting Paid

vINFRASTRUCTURE

1.Unit Testing2.Acceptance Testing3.Automated Deployment4.Continuous Integration5.Issue Tracking

Page 27: TDD and Getting Paid

vINFRASTRUCTURE

1.Unit Testing2.Acceptance Testing3.Automated Deployment4.Continuous Integration5.Issue Tracking

Unit/Acceptance testing

provides the technical base

Page 28: TDD and Getting Paid

vINFRASTRUCTURE

1.Unit Testing2.Acceptance Testing3.Automated Deployment4.Continuous Integration5.Issue Tracking

Unit/Acceptance testing

provides the technical baseAutomated dep

loyment

allows a quick test env.

Page 29: TDD and Getting Paid

vINFRASTRUCTURE

1.Unit Testing2.Acceptance Testing3.Automated Deployment4.Continuous Integration5.Issue Tracking

Unit/Acceptance testing

provides the technical baseAutomated dep

loyment

allows a quick test env.Continuous Inte

gration

makes progress visible

Page 30: TDD and Getting Paid

vINFRASTRUCTURE

1.Unit Testing2.Acceptance Testing3.Automated Deployment4.Continuous Integration5.Issue Tracking

Unit/Acceptance testing

provides the technical baseAutomated dep

loyment

allows a quick test env.Continuous Inte

gration

makes progress visibleIssue Tracking

allows

reporting on TDD

Page 31: TDD and Getting Paid

REPORTING

-1.Code Coverage2.Branch Coverage3.Bug Origin: - tested code - untested code4.Test/Dev Time: - per feature - per story

Page 32: TDD and Getting Paid

REPORTING

-1.Code Coverage2.Branch Coverage3.Bug Origin: - tested code - untested code4.Test/Dev Time: - per feature - per story x

Only track a metric

if it is useful

and encourages the

right behaviour!

Page 33: TDD and Getting Paid

XSKILLS & THE TEAM

Owners not heroes

Prepared to fail

Honest & Disciplined

Page 34: TDD and Getting Paid

aTDD DOES NOTCREATE GOOD

CODE

Wait...What ?

Page 35: TDD and Getting Paid

agood plan

good dev

good code

bad plan

bad dev

bad code

TDD DOES NOTCREATE GOOD

CODE

Page 36: TDD and Getting Paid

8DISASTER RECOVERY

Page 37: TDD and Getting Paid

8Untestable code?

Isolate and contain-or-

Create a testable API

DISASTER RECOVERY

Page 38: TDD and Getting Paid

8Running late?

Drop features-or-

Test the happy path-or-

Test core only

DISASTER RECOVERY

Page 39: TDD and Getting Paid

8Broken build?

Fix the test-or-

Disable the test(or delete it)

DISASTER RECOVERY

Page 40: TDD and Getting Paid

8Team doesn't care

Use incentives/games-or-

Find another job

DISASTER RECOVERY

You're worth it !

Page 41: TDD and Getting Paid

VQUESTIONS?

@rowan_m

thank-youhttp://joind.in/3218