introduction to acceptance test driven development

35
Beginning with the End in Mind: Driving Development with Acceptance Tests Elisabeth Hendrickson Quality Tree Software, Inc. www.qualitytree.com [email protected] Last updated November 10, 2009 This work is licensed under the Creative Commons Attribution 3.0 United States License. View a copy of this license .

Upload: elisabeth-hendrickson

Post on 07-Nov-2014

12.050 views

Category:

Education


1 download

DESCRIPTION

In The Seven Habits of Highly Effective People, Stephen R. Covey names "Begin with the End in Mind" as the second of the seven habits. This habit applies not just to individuals, but to software development teams as well. In Acceptance Test Driven Development (ATDD), the Product Owner begins requirements discussions with expectations and examples, and the whole team collaborates to distill these into acceptance tests that define the essence of “Done." Modern testing frameworks enable the team to express the tests in natural language while connecting them to the software so that the tests are automated while the software is being developed. The end result is that the acceptance tests become executable requirements. These slides explain the ATDD cycle and how it fits with other Agile development and testing practices including TDD, Continuous Integration, and Exploratory Testing.

TRANSCRIPT

Page 1: Introduction to Acceptance Test Driven Development

Beginning with the End in Mind: Driving Development with Acceptance Tests Elisabeth Hendrickson

Quality Tree Software, Inc.

www.qualitytree.com

[email protected]

Last updated November 10, 2009

This work is licensed under the Creative Commons Attribution 3.0 United States License. View a copy of this license.

Page 2: Introduction to Acceptance Test Driven Development

What is ATDD?

Page 3: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Acceptance-Test Driven Development (ATDD) Cycle

!"#$%"&

'"(

)&""*+#",*

!$-./--0&1(/.2

0&1(/.23,.4#15

-21&6-21&6-21&6-21&6-21&6

!"%"#17

(Model developed with Pekka Klärck, Bas Vodde, and Craig Larman.)

Page 4: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

ATDD: Discuss

!"#$%&'()&*+#,

-'#".-'#".-'#".-'#".-'#".

!"#$%&'(&%$)*#(&+(,

Concrete Examples with Expectations

(Slide developed in collaboration with Pekka Klärck.)

Page 5: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

ATDD: Develop

!"#

$%""&'

(")& !"#$

%#$&

'()*+"&

%#$&

'*&+%","-."/,/

,-(*

.&/*/

(Slide developed in collaboration with Pekka Klärck.)

Page 6: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

ATDD: Deliver

FeatureFeature Feature

Feature

Feature

FeatureFeature

Feature

Feature

Product

(Slide developed in collaboration with Pekka Klärck.)

Page 7: Introduction to Acceptance Test Driven Development

Introducing an Example

Page 8: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Start with the Story

As an administrator, I want users creating accounts to be required to choose secure passwords so that their accounts cannot be hacked by someone using a password guessing program.

Page 9: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Discuss

What does “secure” mean

to you? At least 6 characters with

at least one letter, one symbol, and one number.

And if a user provides an insecure password,

display an error message.

Who’s in the room?

Product Owner, Testers,

Developers, and anyone else who will

touch the story.

Page 10: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Capture Concrete Expectations and Examples

Password Valid? “p@ssw0rd” Yes “p@s5” No “passw0rd” No “p@ssword” No “@#$%1234” No

Given a user is creating an account

When they specify an insecure password

Then they see a message, “Passwords must be at least 6 characters long with at least one letter, one number, and one symbol.”

Or can be expressed in tables

Can be expressed as

“Given - When - Then”

Or in other formats depending on the

Framework

Page 11: Introduction to Acceptance Test Driven Development

Why ATDD? Reason #1: Drive Out Ambiguity and Clarify Expectations

Page 12: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

This is not an Argument about a Bug

“Bug Triage Meeting” The Tuesday before release.

Whether or not it’s a bug, if we make a change we’ll blow the

schedule.

It’s a bug.

No it’s not.

Is too.

IS NOT.

IS TOO!

NOT NOT NOT!

Page 13: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Acceptance Tests Define Scope

Page 14: Introduction to Acceptance Test Driven Development

A Short Digression on ATDD-Friendly Tools

Page 15: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Examples of ATDD-Friendly Frameworks

• Cucumber: a Ruby-based BDD tool that supports “Given-When-Then”

• Fitnesse: a table-driven framework that uses a wiki for displaying and editing tests

• Robot Framework: keyword-driven framework that supports text or tables

• Concordion: Java-based framework for expressing expectations in prose

Page 16: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Test “Fixture”

Frameworks, Interfaces, and Drivers

Natural Language

Expectations

GUI

Created in collaboration.

Format defined by the

framework

Code written during development in a

programming language determined by the

framework.

Implementation

“Guts”

Public API

Other interfaces

GUI Driver (e.g. SeleniumRC)

Page 17: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Characteristics of ATDD-Friendly Frameworks

•  Support expressing expectations in a language and format that fits the context

•  Support collaboration among the whole team including developers, testers, & the product owner

•  Connect expectations to the system under test with a minimum of test code (“fixtures,” “libraries,” “steps”) to leverage expectations as executable requirements

•  Play nicely with source control systems and continuous integration

•  Pluggable to support a variety of interfaces

Page 18: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Contrasting View: Traditional Test Automation

Written or recorded after the fact.

Expectations are translated, not

leveraged.

GUI

Implementation

“Guts”

Public API

Other interfaces

Automated Test Scripts:

Combination of business-facing expectations and implementation

details.

Page 19: Introduction to Acceptance Test Driven Development

Back to the Example…

Page 20: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Take the Acceptance Tests…

Password Valid? “p@ssw0rd” Yes “p@s5” No “passw0rd” No “p@ssword” No “@#$%1234” No

Given a user is creating an account

When they specify an insecure password

Then they see a message, “Passwords must be at least 6 characters long with at least one letter, one number, and one symbol.”

(Note that these expectations are

implementation-agnostic and express just the

essence of the expectation.)

Page 21: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

…and Write the Code

Password Valid? “p@ssw0rd” Yes “p@s5” No “passw0rd” No “p@ssword” No “@#$%1234” No

Test “Fixture”

GUI

Implementation

“Guts”

Public API

Other interfaces

Page 22: Introduction to Acceptance Test Driven Development

Why ATDD? Reason #2: Make progress visible.

Page 23: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Are We There Yet?

Page 24: Introduction to Acceptance Test Driven Development

Why ATDD? Reason #3: Leverage, Efficiency, and Executable Specifications

Page 25: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Traditional Approaches

Requirements Management

System

Test Management

System Technical

Specifications

Traceability Matrix

?

Page 26: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Test “Fixture”

Efficiency, Reusability, Maintainability

Natural Language

Expectations

The tests define the

requirements.

New interface? Just add a test

fixture

Implementation

(No reconciling multiple, duplicate

artifacts.)

New Interface

Implementation change? Make a

localized update to the test fixture.

(Preserve valid expectations.)

(Leverage relevant expectations.)

Page 27: Introduction to Acceptance Test Driven Development

How does ATDD fit with the rest of the process?

Page 28: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

ATDD: Part of an Agile Testing Strategy

(A variation on Brian Marick’s Agile Testing Quadrants as published in his essay “Agile Testing Directions”)

Business-facing

Code- facing

Support Critique

Acceptance Tests Exploratory Testing

Unit Tests Reviews, inspections,

pairing, code quality metrics

Page 29: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Tests are Versioned with the Code

Natural Language

Expectations Test

“Fixture” Code

Unit Tests

Production Code

Source Control

Page 30: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Tests Execute as Part of the Automated Build

Continuous Integration

Images courtesy Mike Clark, www.pragmaticautomation.com. Used with permission.

Page 31: Introduction to Acceptance Test Driven Development

Why ATDD? Reason #4: No more bugs. (No, I’m not kidding. But yes, there is a catch.)

Page 32: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Zero Tolerance for Bugs

!"#$%"%&'%()'*+,

!"#$%"%&'%()'*+,

Page 33: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

But Not Everything is a Bug

In this context, a BUG

is behavior that violates the letter

or spirit of the Product Owner’s

expectations for the implemented story.

If the behavior does not violate expectations related to the implemented stories, it’s an item

for the backlog.

Page 34: Introduction to Acceptance Test Driven Development

Given all that… Why not ATDD?

Page 35: Introduction to Acceptance Test Driven Development

Copyr

ight

© 2

01

0 Q

ual

ity

Tre

e So

ftw

are,

Inc.

Resources

Adzic, Gojko (2009). Bridging the Communication Gap: Specification by Example and Agile Acceptance Testing. Neuri Limited.

Crispin, Lisa (2005). “Using Customer Tests to Drive Development.” Methods & Tools. Summer 2005 Issue. Available online at http://www.methodsandtools.com/archive/archive.php?id=23

Crispin, L., & Gregory, J. (2009). Agile Testing: A Practical Guide for Testers and Agile Teams (Addison-Wesley Signature Series (Cohn)). New York: Addison-wesley Professional.

Marick, Brian (2003). “Agile Testing Directions.” (An explanation of business-facing v. code- facing tests.) Available online at http://www.exampler.com/old-blog/2003/08/22/#agile- testing-project-2