xp days - acceptance test driven development

147
Licensed Under Creative Commons by Naresh Jain Acceptance Test Driven Development Naresh Jain [email protected] 1

Upload: alexey-krivitsky

Post on 06-May-2015

3.556 views

Category:

Spiritual


0 download

TRANSCRIPT

Page 2: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Tutorial Schedule

Part discussion, part exercise

Starts light and fluffy

You’ll get your hands dirty by the end

Questions welcomed all the time

2

Page 7: XP Days - 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?

4

Page 8: XP Days - 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)

4

Page 9: XP Days - 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.)

4

Page 10: XP Days - 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)

4

Page 11: XP Days - 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]

4

Page 12: XP Days - 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]

4

Page 14: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance CriteriaAcceptance Criteria & Tests: Definition

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

Are typically provided by the customer or product owner.

Are not a replacement for conversation. Are one of the results of the conversation

Acceptance Criteria are NOT tests

6

Page 15: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

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

7

Page 16: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

8

Page 17: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

8

Page 18: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

+

8

Page 19: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

Examples (data + scenarios)+

8

Page 20: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

Examples (data + scenarios)

Acceptance Tests

+

8

Page 22: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Acceptance Criteria and Tests:

A Critical Piece of Agile

10

Page 23: XP Days - 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

11

Page 24: XP Days - 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 Facing

12

Page 25: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Brian Marick’s Test Categorization

Business Facing

Technology Facing

Supp

orts

Pro

gram

min

gC

ritique product

13

Page 26: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Brian Marick’s Test Categorization

Business Facing

Technology Facing

Acceptance Testing Low-fi prototypes

Unit Testing

Exploratory TestingUI and Usability Testing

Performance Testing

Supp

orts

Pro

gram

min

gC

ritique product

14

Page 27: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

May 1 Jul 1 Sep 1 Nov 1

Analysis

Design

Implementation

Test

Acceptance Criteria & Tests: A Critical Piece of Agile

15

Page 28: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile ApproachAcceptance Criteria & Tests: A Critical Piece of Agile

16

Page 29: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 30: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 31: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

Iteration

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 32: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

IterationAutomated Acceptance

Tests

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 33: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

IterationAutomated Acceptance

Tests

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 34: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

IterationAutomated Acceptance

Tests

AutomatedAcceptance

Tests

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 35: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

IterationAutomated Acceptance

Tests

AutomatedAcceptance

Tests

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 36: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

The Agile Approach

Acceptance Criteria

Acceptance Criteria

IterationAutomated Acceptance

Tests

AutomatedAcceptance

Tests

Acceptance Criteria & Tests: A Critical Piece of Agile

16

Page 37: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Test Driven Development

17

Page 38: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

TDD Rhythm - Test, Code, Refactor

Add a Test

Test Driven Development

17

Page 39: XP Days - 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

17

Page 40: XP Days - 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

17

Page 41: XP Days - 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

17

Page 42: XP Days - 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

17

Page 43: XP Days - 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

17

Page 44: XP Days - 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

17

Page 45: XP Days - 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

17

Page 46: XP Days - 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

17

Page 47: XP Days - 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

17

Page 48: XP Days - 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

17

Page 49: XP Days - 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

17

Page 52: XP Days - 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

18

Page 53: XP Days - 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

18

Page 54: XP Days - 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

18

Page 55: XP Days - 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

18

Page 56: XP Days - 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

18

Page 57: XP Days - 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

19

Page 58: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Manual Acceptance TestsAcceptance Tests: A Critical Piece of Agile

20

Page 59: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Manual Acceptance Tests

Manual Acceptance Tests

Acceptance Tests: A Critical Piece of Agile

20

Page 60: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Manual Acceptance Tests

Manual Acceptance Tests

Acceptance Tests: A Critical Piece of Agile

20

Page 61: XP Days - 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

21

Page 62: XP Days - 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

22

Page 64: XP Days - 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

24

Page 69: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Criteria for DONE

Automated

Executable Specification

+

25

Page 70: XP Days - 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

26

Page 72: XP Days - 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?

28

Page 73: XP Days - 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?

29

Page 74: XP Days - 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?

30

Page 76: XP Days - 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

32

Page 78: XP Days - 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

34

Page 79: XP Days - 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

34

Page 80: XP Days - 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’

34

Page 81: XP Days - 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’

34

Page 82: XP Days - 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

34

Page 83: XP Days - 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

35

Page 84: XP Days - 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

35

Page 85: XP Days - 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

35

Page 86: XP Days - 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

35

Page 87: XP Days - 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

35

Page 88: XP Days - 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

36

Page 89: XP Days - 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

37

Page 90: XP Days - 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

37

Page 91: XP Days - 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

37

Page 92: XP Days - 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

37

Page 93: XP Days - 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

37

Page 95: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Good Acceptable Criteria and Tests

S - SPECIFIC - Explicitly defined and definite

38

Page 96: XP Days - 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

38

Page 97: XP Days - 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

38

Page 98: XP Days - 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

38

Page 99: XP Days - 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

38

Page 100: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Avoid Implementation Details

System

Database

Tests

DatabaseDatabase

UI

Writing Good Acceptance Tests

39

Page 101: XP Days - 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

40

Page 103: XP Days - 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

42

Page 104: XP Days - 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

SharpRobo

RSpec/JBehave

Tools

43

Page 105: XP Days - 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

44

Page 106: XP Days - 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

45

Page 107: XP Days - 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

46

Page 109: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Only Tables ExecuteThinking in Tables

Ignored

Executed

48

Page 110: XP Days - 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

49

Page 111: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

3 Foundation Fixtures

Column Fixture

Row Fixture

Action Fixture

copyright (c) 2007 by Micah Martin & Naresh Jain. All rights reserved.

Thinking in Tables

50

Page 113: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Row FixtureAnalogous to comparing against rows in a database table

Thinking in Tables

52

Page 114: XP Days - 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

53

Page 115: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

FitLibrary

Extension to FIT

Written by Rick Mugridge

Adds some handy Fixtures

54

Page 116: XP Days - 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

55

Page 117: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Text

DoFixture

• Broken tables

• Highly readable

• Flexibility

FitLibrary

56

Page 119: XP Days - 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

58

Page 120: XP Days - 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

59

Page 121: XP Days - 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

60

Page 122: XP Days - 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

61

Page 125: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Organizing Tests

Allowing customers to add new tests without breaking the build

Patterns

64

Page 126: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Version Control

Keeping the acceptance test in version control with the code.

Patterns

65

Page 127: XP Days - 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

66

Page 130: XP Days - 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

69

Page 131: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Dynamic Stubbing

Avoiding complications of external systems.

Patterns

70

Page 132: XP Days - 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

71

Page 133: XP Days - 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

72

Page 134: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

DRY

Using !include to avoid repeating yourself.

Patterns

73

Page 135: XP Days - 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

74

Page 136: XP Days - 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

75

Page 137: XP Days - 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

76

Page 139: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Developer ATs

Developers writing acceptance tests by themselves, for themselves.

Anti-Patterns

78

Page 140: XP Days - 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

79

Page 141: XP Days - 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

80

Page 142: XP Days - 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

81

Page 143: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Test After

Writing tests after the code is already written.

Anti-Patterns

82

Page 144: XP Days - Acceptance Test Driven Development

Licensed Under Creative Commons by Naresh Jain

Hidden Test Data

Hiding test data in the fixtures.

Anti-Patterns

83

Page 145: XP Days - 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

84

Page 146: XP Days - 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

85