TDD and Getting Paid

Post on 05-Dec-2014

5.641 views 0 download

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

uf

Test DrivenDevelopment

andGetting Paid

!

Rowan MerewoodSoftware Eng. / Team Lead

Ibuildings

m

WHO AM I?

Software Engineer &Technical Team Leadat Ibuildings UK

I want to write good codeand earn a living

@rowan_m

WHO AM I?Not ?

si-am-not-a

Cconsultant

well-maybe-a-little

s

WHO AM I?Not ?

i-am-not

selling-a

book

s

WHO AM I?Not ?

i-am-not

a-slave-to

one=method

@THE GOOD

Clean code, smart devsLatest technology

Building your career

Elitist / Intimidating?

DIFFERENT SITUATIONS

gTHE BAD

Disgusting codeDevs don't careCareer dead-end

Changes break the app.Always bug-fixing

DIFFERENT SITUATIONS

cTHE UGLY

Good tests are hardWriting tests takes time

Time is money

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

DIFFERENT SITUATIONS

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

WHAT IS TDD?

RED

GREEN

REFACTORHsimplify

lWHY IS THIS HARD?

Do you know whatyou want

before

you code it?

lWHY IS THIS HARD?

Does your clientknow whatthey want?

Ever?

Train yourself to think like a scientist

1.Hypothesis2.Repeatable Experiment3.Conclusions ]

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.

!DAVE THOMAS

co-author ofThe PragmaticProgrammer

Code Katahttp://codekata.pragprog.com/

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”

.ROY OSHEROVE - TDD Kata

demo

Now you're an expert...

Do not assume you canjust start to do thisin your project

warning

D

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

LDIFFERENT APPROACHES

Force testson your client

Make your clientwant the tests

LFORCING TESTS

Add a fixed percentageto your estimates.

Do not compromiseyour principles.

LSELLING TESTS

Use tests to define 'done'.

Involve the clientin creating tests.

Make the testsa deliverable.

LSELLING TESTS

Use tests to define 'done'.

Involve the clientin creating tests.

Make the testsa deliverable.

Fitnesse Frameworkhttp://fitnesse.org/

LSELLING TESTS

Use tests to define 'done'.

Involve the clientin creating tests.

Make the testsa deliverable.

Seleniumhttp://seleniumhq.org/

Fitnesse Frameworkhttp://fitnesse.org/

DDON'T BELIEVE THE HYPE

Make sure you don't over-promise.

Make sure you have theinfrastructure and skills

NO SILVER BULLETS

vINFRASTRUCTURE

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

vINFRASTRUCTURE

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

Unit/Acceptance testing

provides the technical base

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.

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

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

REPORTING

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

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!

XSKILLS & THE TEAM

Owners not heroes

Prepared to fail

Honest & Disciplined

aTDD DOES NOTCREATE GOOD

CODE

Wait...What ?

agood plan

good dev

good code

bad plan

bad dev

bad code

TDD DOES NOTCREATE GOOD

CODE

8DISASTER RECOVERY

8Untestable code?

Isolate and contain-or-

Create a testable API

DISASTER RECOVERY

8Running late?

Drop features-or-

Test the happy path-or-

Test core only

DISASTER RECOVERY

8Broken build?

Fix the test-or-

Disable the test(or delete it)

DISASTER RECOVERY

8Team doesn't care

Use incentives/games-or-

Find another job

DISASTER RECOVERY

You're worth it !

VQUESTIONS?

@rowan_m

thank-youhttp://joind.in/3218