introducing bdd elements to unit testing.pptx

17
Experiences introducing BDD and BDD elements To unit testing and a legacy codebase XP 2010, June 3rd 2010

Upload: anders-hammervold

Post on 26-Jun-2015

1.010 views

Category:

Technology


0 download

DESCRIPTION

My lightning talk on xp2010 desciribing experiences from 5 projects with introducing BDD or BDD elements to unit testing

TRANSCRIPT

Page 1: Introducing bdd elements to unit testing.pptx

Experiences introducing BDD and BDD elements

To unit testing and a legacy codebase

XP 2010, June 3rd 2010

Page 2: Introducing bdd elements to unit testing.pptx

Background

A local, familyman, 2 children

Developer, Consultant

BEKK Consulting

10+ years

Seen many types of projects

@ah74

hammervold.com/anders

Page 3: Introducing bdd elements to unit testing.pptx

Background: What I had seen a lot of

POUT

Some testclasses of several k+ lines

Often excellent testcode

Difficult to understand for others

Difficult to come back to after some time away

Focus on test techniques like Mocking

Refactoring later would mean rewriting complex code AND complex tests

in a hurry? remove tests that are red

Page 4: Introducing bdd elements to unit testing.pptx

BDD and ”BDD elements”

BDD

Started seeing BDD inspired syntax and thinking

Ground up

Which effect did this have ?

Did it correspond with the goals of BDD?

What was happening in other projects right now ?

Examples

Page 6: Introducing bdd elements to unit testing.pptx

Example: ”BDDTest”

Adapted from and inpired by code and examples from: Torbjørn Marø and Jonas follesø

Page 7: Introducing bdd elements to unit testing.pptx

Example: ”BDDTest” adapted

Page 8: Introducing bdd elements to unit testing.pptx

Example: Glue

Tore Vestues, http://glue.codeplex.com

Page 9: Introducing bdd elements to unit testing.pptx

Experiment: Regions

Experimental,

IDE-specific

Page 10: Introducing bdd elements to unit testing.pptx

Effects: The skeptic

”I know how to write tests”

Page 11: Introducing bdd elements to unit testing.pptx

Effects: The skeptic

”Wow this test became so much simpler!”

”This was almost fun”

Page 12: Introducing bdd elements to unit testing.pptx

How

~20 minute interviews

– Developers

– Testers

– Customers

5 different projects

– May 2010

Page 13: Introducing bdd elements to unit testing.pptx

Objections?

Some arguments used were the same as against TDD

Fear of change

Technical problems, sometimes new technology

Unwillingness to learn something new

Not true BDD, outside in through ui

Page 14: Introducing bdd elements to unit testing.pptx

Developer perspective

Clear sense of purpose

Recipe to follow

Renewed focus on specification

Smaller, simpler tests

Easier to maintain

Most tests now got a similar structure

Greater number of tests but better organised

”I give up, i’ll rather go write some BDD-tests,

maybe that will cheer me up”

Page 15: Introducing bdd elements to unit testing.pptx

Customer perspective

”The bug-rate dropped significantly”

”I could see that they (the developers) had understood what I meant”

”I never understood the code anyway”

– Generally responded well to the syntax

– Customers were generally more agile than developers perhaps expected

– When given a chance

– Clarifying requirements

Page 16: Introducing bdd elements to unit testing.pptx

Success

Many of the results can be attributed to TDD

BDD elements added to and amplified these

Skeptics became ”believers”

The customers showed greater involvement

Testers could write features in the error report

Page 17: Introducing bdd elements to unit testing.pptx

Some success-criteria

Access to a mentor

Commitment from the team

Willingness to learn

Including the customer