179
Licensed Under Creative Commons by Naresh Jain Acceptance Test Driven Development Naresh Jain [email protected] http://blogs.agilefaqs.com 1

ATDD - Acceptance Test Driven Development

Embed Size (px)

DESCRIPTION

Acceptance test driven development tutorial. This tutorial explains how to take user stories and convert them into working software. Details about Acceptance Criteria and Acceptance tests using FitNesse and FitLibrary are described in this presentation. Also Patterns and Anti-Patterns associated with this are described in this presentation.

Citation preview

Page 3: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Warmup ScenariosPick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

2

Page 4: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Warmup ScenariosPick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

Going out for Movie (THX sound and Digital projection)

2

Page 5: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Warmup ScenariosPick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

Going out for Movie (THX sound and Digital projection)

Going out for meal (one veg.)

2

Page 6: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Warmup ScenariosPick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

Going out for Movie (THX sound and Digital projection)

Going out for meal (one veg.)

Going shopping ($50)

2

Page 7: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Warmup ScenariosPick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

Going out for Movie (THX sound and Digital projection)

Going out for meal (one veg.)

Going shopping ($50)[10 Minutes]

2

Page 8: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Warmup ScenariosPick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

Going out for Movie (THX sound and Digital projection)

Going out for meal (one veg.)

Going shopping ($50)[10 Minutes]

Present back to the group your findings. [3 minutes per group]

2

Page 9: ATDD - Acceptance Test Driven Development

Story is a smallest piece of functionality that add business value

What is a Story?

Ron Jeffries’ 3 Cs - Card, Conversation and Confirmation

As a .. <user who requires this feature>

I want .. <do something>

So that... <user goal/business justification>

Story Title - Actor Action Context

3

Page 10: ATDD - Acceptance Test Driven Development

Title: Keen Reader subscribes to a blog

As a keen reader of your blog

I want to subscribe to your blog

So that I can stay up-to-date with the new posts

Story Example

4

Page 11: ATDD - Acceptance Test Driven Development

Title: Social Networking Enthusiast uploads profile picture

As a Social Networking Enthusiast

I want to upload my profile picture

So my friends can see how I look and recognize me

Another Story Example

5

Page 12: ATDD - Acceptance Test Driven Development

What makes a good Story?

6

Page 13: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

What makes a good Story?

6

Page 14: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

Independent

What makes a good Story?

6

Page 15: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

Independent

Negotiable

What makes a good Story?

6

Page 16: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

Independent

Negotiable

Valuable

What makes a good Story?

6

Page 17: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

Independent

Negotiable

Valuable

Estimate-able

What makes a good Story?

6

Page 18: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

Independent

Negotiable

Valuable

Estimate-able

Small

What makes a good Story?

6

Page 19: ATDD - Acceptance Test Driven Development

Stories should follow the INVEST principle:

Independent

Negotiable

Valuable

Estimate-able

Small

Testable

What makes a good Story?

6

Page 20: ATDD - Acceptance Test Driven Development

Stories are fundamental unit of activity

7

Page 21: ATDD - Acceptance Test Driven Development

Business Goals

Stories are fundamental unit of activity

7

Page 22: ATDD - Acceptance Test Driven Development

Business Goals

Inception

Stories are fundamental unit of activity

7

Page 23: ATDD - Acceptance Test Driven Development

As a ____, I want to be able to ____ so

that ____

Product Backlog

Might have an initial estimate (perhaps for both analysis and development), and an expression of technical and

business confidence that this is real and achievable

Business Goals

Inception

Stories are fundamental unit of activity

7

Page 24: ATDD - Acceptance Test Driven Development

As a ____, I want to be able to ____ so

that ____

Product Backlog

Might have an initial estimate (perhaps for both analysis and development), and an expression of technical and

business confidence that this is real and achievable

Release planning

Business Goals

Inception

Stories are fundamental unit of activity

7

Page 25: ATDD - Acceptance Test Driven Development

As a ____, I want to be able to ____ so

that ____

Product Backlog

Might have an initial estimate (perhaps for both analysis and development), and an expression of technical and

business confidence that this is real and achievable

As a ____, I want to be able to ____ so

that ____

I will know this is done when _______

Release Backlog

More detailed estimate, and a specific acceptance test – low confidence stories might be

“spiked” or prototyped

Release planning

Business Goals

Inception

Stories are fundamental unit of activity

7

Page 26: ATDD - Acceptance Test Driven Development

As a ____, I want to be able to ____ so

that ____

Product Backlog

Might have an initial estimate (perhaps for both analysis and development), and an expression of technical and

business confidence that this is real and achievable

As a ____, I want to be able to ____ so

that ____

I will know this is done when _______

Release Backlog

More detailed estimate, and a specific acceptance test – low confidence stories might be

“spiked” or prototyped

Release planning Sprint planning

Business Goals

Inception

Stories are fundamental unit of activity

7

Page 27: ATDD - Acceptance Test Driven Development

As a ____, I want to be able to ____ so

that ____

Product Backlog

Might have an initial estimate (perhaps for both analysis and development), and an expression of technical and

business confidence that this is real and achievable

As a ____, I want to be able to ____ so

that ____

I will know this is done when _______

Release Backlog

More detailed estimate, and a specific acceptance test – low confidence stories might be

“spiked” or prototyped

As a ____, I want to be able to ____ so

that ____

I will know this is done when _______

To do this I must:1) _____2) _____

Sprint Backlog

Possible automation of the acceptance

test

Development team breaks out the detail of work needed to

pass test

Release planning Sprint planning

Business Goals

Inception

Stories are fundamental unit of activity

7

Page 28: ATDD - Acceptance Test Driven Development

Is a set of conditions that the Story must meet for it to be accepted as complete

Is typically provided by the customer or product owner.

Is not a replacement for conversation.

Is the results of the conversation

Acceptance Criteria are NOT tests

Acceptance Criteria

8

Page 29: ATDD - Acceptance Test Driven Development

Acceptance Criteria should contain:

ACTOR

VERB – DESCRIBING A BEHAVIOR

OBSERVABLE RESULT

To accommodate pre-conditions Acceptance Criteria can be expressed as

Given [Precondition]

When [Actor + Action]

Then [Observable Result]

Writing Acceptance Criteria

9

Page 30: ATDD - Acceptance Test Driven Development

ExampleSocial Networking Enthusiast uploads profile picture

10

Page 31: ATDD - Acceptance Test Driven Development

Example

Given the user has a valid facebook account and a digital picture on her computer,

When she uploads a picture in facebook,

Then her the picture should be visible to all her friends in her network.

Social Networking Enthusiast uploads profile picture

10

Page 32: ATDD - Acceptance Test Driven Development

Example

Given the user has a valid facebook account and a digital picture on her computer,

When she uploads a picture in facebook,

Then her the picture should be visible to all her friends in her network.

Given an user is trying to find a friend on facebook,

When the user searches for a person using their name,

Then their profile picture should be displayed along with other details.

Social Networking Enthusiast uploads profile picture

10

Page 33: ATDD - Acceptance Test Driven Development

Example

Given the user has a valid facebook account and a digital picture on her computer,

When she uploads a picture in facebook,

Then her the picture should be visible to all her friends in her network.

Given an user is trying to find a friend on facebook,

When the user searches for a person using their name,

Then their profile picture should be displayed along with other details.

As owner of facebook,

I want users to upload authentic, personal profile picture,

So facebook's reputation remains intact and facebook stays out of legal hassles.

Social Networking Enthusiast uploads profile picture

10

Page 34: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

11

Page 35: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

11

Page 36: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

+

11

Page 37: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

Examples (data + scenarios)+

11

Page 38: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

Examples (data + scenarios)

Acceptance Tests

+

11

Page 39: ATDD - Acceptance Test Driven Development

TasksTeam members further break down each story into tasks that need

to be completed to meet the acceptance criteria for the story.

12

Page 40: ATDD - Acceptance Test Driven Development

Tasks

To accomplish this story:

we start off with a simple upload and image display

Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.

12

Page 41: ATDD - Acceptance Test Driven Development

Tasks

To accomplish this story:

we start off with a simple upload and image display

restrict user to only upload certain image types (gif, jpg and png)

Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.

12

Page 42: ATDD - Acceptance Test Driven Development

Tasks

To accomplish this story:

we start off with a simple upload and image display

restrict user to only upload certain image types (gif, jpg and png)

figure out where to store the image. (performant and fault-tolarent)

Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.

12

Page 43: ATDD - Acceptance Test Driven Development

Tasks

To accomplish this story:

we start off with a simple upload and image display

restrict user to only upload certain image types (gif, jpg and png)

figure out where to store the image. (performant and fault-tolarent)

scale down (size, resolution, etc.) of the image

Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.

12

Page 44: ATDD - Acceptance Test Driven Development

Tasks

To accomplish this story:

we start off with a simple upload and image display

restrict user to only upload certain image types (gif, jpg and png)

figure out where to store the image. (performant and fault-tolarent)

scale down (size, resolution, etc.) of the image

and so on...

Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.

12

Page 48: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Only Tables ExecuteThinking in Tables

Ignored

Executed

16

Page 49: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Foundational Table Structure

Name of Fixture

Interaction with Application

Table structure depends on type of Fixture

Thinking in Tables

17

Page 50: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

3 Foundation Fixtures

Column Fixture

Row Fixture

Action Fixture

Thinking in Tables

18

Page 52: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Row FixtureAnalogous to comparing against rows in a database table

Thinking in Tables

20

Page 53: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Action Fixture

Think GUI window Counter WindowCounter:

Counter: 6 Count

public class CountFixture extends Fixture { private int counter = 0; public void count() { counter++; } public int counter() { return counter; }}

Thinking in Tables

21

Page 54: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

FitLibrary

Extension to FIT

Written by Rick Mugridge

Adds some handy Fixtures

22

Page 55: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

FitLibrary Fixtures

ArrayFixture for ordered lists

SetFixture for unordered lists

SetUpFixture

Supports

Graphics

Tree structures

Nested Tables

FitLibrary

23

Page 56: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

DoFixture

• Broken tables

• Highly readable

• Flexibility

FitLibrary

24

Page 57: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

FIT

Framework for Integrated Tests

Created by Ward Cunningham

Open Source

The most accepted solution for agile acceptance testing

Tools

25

Page 58: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

FitNesse

Environment build around FIT

Makes everything easier

Created by Object Mentor, Inc.

Open Source

Tools

26

Page 59: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

FIT FitNesse

- Tests written in HTML- Tests are executed on the command line- Tables are executed- Non-table markup is ignored- Tables map to Fixtures- Fixtures are code that is aware of the system- Supplies foundational Fixtures- Implementations ported to many languages

- Stand alone web server- Is a wiki- Tests written in wiki text- Tests are executed from within the wiki- Translates tests into HTML- Uses FIT to execute tests- Supports test suites- Supports variables in tests- Supports test refactoring- Written in Java- Supports FIT implementations in any language

27

Page 60: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Criteria and Tests:

A Critical Piece of Agile

28

Page 61: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Analysis

Design

Implementation

DFDERD

DDST

1 May 1 Nov1 Jul 1 Sep

Traditional ApproachAcceptance Criteria & Tests: A Critical Piece of Agile

29

Page 62: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Key Questions

Are we building the right product?

Are we building the product right?

Business Facing

Technology/Implementation Facing

30

Page 63: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Brian Marick’s Test Categorization

Business Facing

Technology/Implementation Facing

Supp

orts

Pro

gram

min

gC

ritique product

31

Page 64: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

It Helps to Think of Tests this way...

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique product

32

Page 65: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

It Helps to Think of Tests this way...

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique productUnit Testing

32

Page 66: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

It Helps to Think of Tests this way...

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique productUnit Testing

Acceptance Testing Low-fi prototypes

32

Page 67: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

It Helps to Think of Tests this way...

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique productUnit Testing

Acceptance Testing Low-fi prototypes

Exploratory TestingUI and Usability Testing

32

Page 68: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

It Helps to Think of Tests this way...

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique productUnit Testing

Acceptance Testing Low-fi prototypes

Exploratory TestingUI and Usability Testing

Performance TestingSystem Tests

32

Page 69: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Avatars of TDD

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique product

Outside In

Inside Out

33

Page 70: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Test Driven Development

34

Page 71: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Test Driven Development

34

Page 72: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Test Driven Development

34

Page 73: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the TestPass

Test Driven Development

34

Page 74: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Fail

Pass

Test Driven Development

34

Page 75: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Fail

Pass

Test Driven Development

34

Page 76: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Fail

Pass

Test Driven Development

34

Page 77: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Fail

Fail

Pass

Test Driven Development

34

Page 78: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Fail

Pass

Fail

Pass

Test Driven Development

34

Page 79: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Refactor

Fail

Pass

Fail

Pass

Test Driven Development

34

Page 80: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Refactor

Fail

Pass

Fail

Pass

Test Driven Development

34

Page 81: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Refactor

Fail

Pass

Fail

Pass

Test Driven Development

34

Page 82: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Refactor

Fail

Pass

Fail

Pass

Test Driven Development

34

Page 85: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven Development

Story

Acceptance Criteria

35

Page 86: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Story

Acceptance Criteria

35

Page 87: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

Story

Acceptance Criteria

35

Page 88: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

Story

Acceptance Criteria

Automated Unit Test

35

Page 89: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

AutomatedAcceptance

Tests

Story

Acceptance Criteria

Automated Unit Test

35

Page 90: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

AutomatedAcceptance

Tests

Story

Acceptance Criteria

ExploratoryTesting

Automated Unit Test

35

Page 91: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

AutomatedAcceptance

Tests

Story

Acceptance Criteria

Acceptance Criteria

ExploratoryTesting

Automated Unit Test

35

Page 92: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

AutomatedAcceptance

Tests

Story

Acceptance Criteria

Acceptance Criteria

ExploratoryTesting

Automated UI Tests

Automated Unit Test

35

Page 93: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Test Driven DevelopmentIteration

Automated Acceptance

Tests

AutomatedAcceptance

Tests

Story

Acceptance Criteria

Acceptance Criteria

ExploratoryTesting

Automated UI Tests

TESTS

PERFORMENCE

Automated Unit Test

35

Page 96: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Mike Cohn’s Testing Pyramid

GUITests

Small in NumberTools: Selenium, Sahi, Watir, Abbot, Frankenstein

36

Page 97: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Mike Cohn’s Testing Pyramid

AcceptanceTests

GUITests

Small in NumberTools: Selenium, Sahi, Watir, Abbot, Frankenstein

36

Page 98: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Mike Cohn’s Testing Pyramid

AcceptanceTests

GUITests

Small in NumberTools: Selenium, Sahi, Watir, Abbot, Frankenstein

At least one per storyTools: Fit, FitNesse, RSpec, JBehave

36

Page 99: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Mike Cohn’s Testing Pyramid

Unit Tests

AcceptanceTests

GUITests

Small in NumberTools: Selenium, Sahi, Watir, Abbot, Frankenstein

At least one per storyTools: Fit, FitNesse, RSpec, JBehave

36

Page 100: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Mike Cohn’s Testing Pyramid

Unit Tests

AcceptanceTests

GUITests

Small in NumberTools: Selenium, Sahi, Watir, Abbot, Frankenstein

At least one per storyTools: Fit, FitNesse, RSpec, JBehave

At least one per class or moduleTools: xUnit, TestNG

36

Page 101: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Every story must have at least one Acceptance Test

A story is not DONE until it passes it’s Acceptance Tests

Criteria for DONEAcceptance Tests: A Critical Piece of Agile

37

Page 102: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Manual Acceptance TestsAcceptance Tests: A Critical Piece of Agile

38

Page 103: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Manual Acceptance Tests

Manual Acceptance Tests

Acceptance Tests: A Critical Piece of Agile

38

Page 104: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Manual Acceptance Tests

Manual Acceptance Tests

Acceptance Tests: A Critical Piece of Agile

38

Page 105: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Why Acceptance Tests?

Criteria for Completion

Great Collaboration tool

Source of Feedback

Real data to measure progress

39

Page 106: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Data From Acceptance Tests

0

18

36

54

72

90

1 2 3 4 5 6 7 8 9 10

Total ATs Failing ATs Passing ATs

40

Page 108: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Button

How often would you press it?

When would you press it?

Who would press it?

Testers, Developers, Managers, Customers, Spectators, etc.

Acceptance Tests: A Critical Piece of Agile

42

Page 113: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Criteria for DONE

Automated

Executable Specification

+

43

Page 114: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Executable Specification

A new paradigm for testing

Puts quality first

Removes ambiguity from requirements

Acceptance Tests: A Critical Piece of Agile

44

Page 116: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Customer

The Customer Role

Stake holder

Business Analyst

Quality Assurance

Product Owner

Developer

Who Writes Acceptance Tests?

46

Page 117: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Tests Get Technical

The “Customer” may need technical help to write tests

Developers and QAs are technical

Pair test authoring

Who Writes Acceptance Tests?

47

Page 118: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Business Rules Get Fuzzy

Sometimes developers need help understanding tests

Customers know business rules

Pair test implementation

Who Writes Acceptance Tests?

48

Page 120: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Login Test

Write a test plan, in plain text, for the business rules of logging in.

Web application

User credentials are stored in relational database

Successful login redirects to “Welcome” page

Exercise #1

50

Page 122: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test PossibilitiesWriting Good Acceptance Tests

1. Direct browser to URL for login page

52

Page 123: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test PossibilitiesWriting Good Acceptance Tests

1. Direct browser to URL for login page

52

Page 124: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test PossibilitiesWriting Good Acceptance Tests

1. Direct browser to URL for login page

1. Enter the username ‘wallace’

52

Page 125: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test PossibilitiesWriting Good Acceptance Tests

1. Direct browser to URL for login page

1. Enter the username ‘wallace’

52

Page 126: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test PossibilitiesWriting Good Acceptance Tests

1. Direct browser to URL for login page

1. Enter the username ‘wallace’

Build a Testable Environment First

52

Page 127: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Add some users to the system

Writing Good Acceptance Tests

53

Page 128: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Add some users to the system

Writing Good Acceptance Tests

53

Page 129: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Add some users to the system

3. Enter a value into the username field

Writing Good Acceptance Tests

53

Page 130: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Add some users to the system

3. Enter a value into the username field

Writing Good Acceptance Tests

53

Page 131: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Add some users to the system

3. Enter a value into the username field

Be Specific

Writing Good Acceptance Tests

53

Page 132: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Tests are Examples

Use concrete examples

Specify concrete behavior

No ambiguity allowed

Writing Good Acceptance Tests

54

Page 133: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Insert into User table values (’wallace’, ‘ilikecheeze’)

Writing Good Acceptance Tests

55

Page 134: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Insert into User table values (’wallace’, ‘ilikecheeze’)

Writing Good Acceptance Tests

55

Page 135: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Insert into User table values (’wallace’, ‘ilikecheeze’)

2. Open a browser to the URL http://localhost/myapp

Writing Good Acceptance Tests

55

Page 136: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Insert into User table values (’wallace’, ‘ilikecheeze’)

2. Open a browser to the URL http://localhost/myapp

Writing Good Acceptance Tests

55

Page 137: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test Possibilities

1. Insert into User table values (’wallace’, ‘ilikecheeze’)

2. Open a browser to the URL http://localhost/myapp

Avoid Implementation Details

Writing Good Acceptance Tests

55

Page 139: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Good Acceptable Criteria and Tests

S - SPECIFIC - Explicitly defined and definite

56

Page 140: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Good Acceptable Criteria and Tests

S - SPECIFIC - Explicitly defined and definite

M - MEASURABLE - Possible to observe and quantify

56

Page 141: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Good Acceptable Criteria and Tests

S - SPECIFIC - Explicitly defined and definite

M - MEASURABLE - Possible to observe and quantify

A - ACHIEVABLE - Capable of existing or taking place

56

Page 142: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Good Acceptable Criteria and Tests

S - SPECIFIC - Explicitly defined and definite

M - MEASURABLE - Possible to observe and quantify

A - ACHIEVABLE - Capable of existing or taking place

R - RELEVANT - Having a connection with the story

56

Page 143: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Good Acceptable Criteria and Tests

S - SPECIFIC - Explicitly defined and definite

M - MEASURABLE - Possible to observe and quantify

A - ACHIEVABLE - Capable of existing or taking place

R - RELEVANT - Having a connection with the story

T - TIME-BOUND – When will the outcome be observed

56

Page 144: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Avoid Implementation Details

Business Tier

View

Data Store

Acceptance Tests

DatabaseDatabase

UI

Writing Good Acceptance Tests

Model and Presenter

57

Page 145: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Login Test: Possible Solution

Add user to system: (’wallace’, ‘ilikecheeze’)

Process login with username ‘wallace’ and password ‘blah’

Check login failed

Process login with username ‘wallace’ and password ‘ilikecheeze’

Check login succeeded

Writing Good Acceptance Tests

58

Page 147: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Commercial Tools

WinRunner

Silk

RFT

Tools

Are not suitable for Acceptance Testing in an Agile environment

TestPartner

QTP

Squish

EggPlant

TestComplete

WindowTester

60

Page 148: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Open Source Options

FIT

FitNesse

Selenium

Among the few tools that support Test Driven Development

Sahi

Watir

Abbot

Frankenstein

Cucumber

RSpec/JBehave

Tools

61

Page 150: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

What is it?

A collaborative web site

Editable by any

Created by Ward Cunningham

Every project should have one

http://c2.com/wiki

http://en.wikipedia.com

Wiki

63

Page 151: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Creating Tests

Use Wiki syntax to create a page with test tables Label the page as a Test Page

Use a page name of the form Test… Turn on the Test property

Make sure your Fixtures are in the classpath Use !path widget

Mechanics !path values are concatenated Java command to start FitServer is executed Testable HTML is passed to FitServer FitServer runs the tests Results are passed back to FitNesse

Wiki

64

Page 152: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Creating Suites

Set the Suite property Create a page with the Suite property Created test pages inside this page When the suite is executed, all child test pages will

be included in the suite execution Use the !see widget

!see <name of test page> All “included” tests pages will be included in the

suite execution

There are 2 ways to make Suites

Run a Suite by clicking the Suite button

Wiki

65

Page 153: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Hands-on Session

Conference Proposal Submission Portal

Some sample Stories

Should be able to submit new proposalShould be able to list all submitted proposalSubmitting proposal with same title should display appropriate error messageShould be able to delete submitted proposal based on the title Should be able to delete submitted proposal based on the titleShould be able to search proposals by titleShould be able to search proposals by IDShould be able to find all proposal by an author's name

66

Page 156: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Organizing Tests

Allowing customers to add new tests without breaking the build

Patterns

69

Page 157: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Version Control

Keeping the acceptance test in version control with the code.

Patterns

70

Page 158: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Cross-Functional Pairing

Using FitNesse based acceptance tests for collaboration between cross-functional team members.

Patterns

71

Page 161: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Independent Tests

Tests shouldn’t depend on each other.

Tests leave the system in the same state it started in.

Patterns

74

Page 162: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Dynamic Stubbing

Avoiding complications of external systems.

Patterns

75

Page 163: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Non-Production Setup/Teardown

Using non-production light weigh code for setup and teardown.

Helps test only what you want to test.

Patterns

76

Page 164: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Suite Levels

Creating different levels of suites depending on the depth/level of feedback desired.

Smoke, Current Iteration/Sprint, Regression

Patterns

77

Page 165: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

DRY

Using !include to avoid repeating yourself.

Patterns

78

Page 166: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Make it Real

Write ATs as close as possible to the real environment.

Patterns

79

Page 167: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Fixture Evolution

Allow Fixture implementation to evolve over time.

Treat fixtures as first class citizens.

Patterns

80

Page 168: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

At Least One Test/Story

Every story should have at least one acceptance test

Avoid long/multipurpose tests.

Patterns

81

Page 170: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Developer ATs

Developers writing acceptance tests by themselves, for themselves.

Anti-Patterns

83

Page 171: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Unit Testing

Don’t write ATs at the unit testing level

Unit tests are implementation specific

ATs are NOT implementation specific

Anti-Patterns

84

Page 172: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

QA Testing Tool

Hard to write tests up front.

Perhaps only on large projects.

Anti-Patterns

85

Page 173: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Silver Bullet

Trying to use FitNesse for all types of Acceptance Tests

UI testing

XML testing

Anti-Patterns

86

Page 174: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Test After

Writing tests after the code is already written.

Anti-Patterns

87

Page 175: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Hidden Test Data

Hiding test data in the fixtures.

Anti-Patterns

88

Page 176: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Implementation Dependent ATs

Making test pages (tables) dependent on implementation details and data structures.

Anti-Patterns

89

Page 177: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Logging in Your Fixtures

Putting log statements or print statements in the fixture code.

Fixtures are probably too complicated.

Anti-Patterns

90

Page 178: ATDD - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Reference

Portions of this presentation is adopted from Micah Martin’s Introduction to Automated Acceptance Tests Presentation

Kent Beck, Test Driven Development By Example.

"Agile Testing Directions" - Brian Marick

http://www.opensourcetesting.org/

91