acceptance test-driven development: mastering agile testing

48
MF AM HalfͲday Tutorial 11/11/2013 8:30 AM "Acceptance Test-Driven Development: Mastering Agile Testing" Presented by: Nate Oster CodeSquads, LLC Brought to you by: 340 Corporate Way, Suite 300, Orange Park, FL 32073 888Ͳ268Ͳ8770 ͼ 904Ͳ278Ͳ0524 ͼ [email protected] ͼ www.sqe.com

Upload: techwellpresentations

Post on 14-Jan-2015

558 views

Category:

Technology


0 download

DESCRIPTION

On agile teams, testers can struggle to keep up with the pace of development if they continue employing a waterfall-based verification process—finding bugs after development. Nate Oster challenges you to question waterfall assumptions and replace this legacy verification testing with acceptance test-driven development (ATDD). With ATDD, you “test first” by writing executable specifications for a new feature before development begins. Learn to switch from “tests as verification” to “tests as specification” and to guide development with acceptance tests written in the language of your business. Get started by joining a team for a simulation and experience how ATDD helps build quality in instead of trying to test defects out. Then progress to increasingly more realistic scenarios and practice the art of specifying intent with plain-language and table-based formats. This isn’t a “tools” session. These are tabletop, paper-based simulations that give you meaningful practice with how executable specifications change the way you think about tests and collaborate as a team. Leave empowered with a kit of exercises to advocate ATDD with your own teams.

TRANSCRIPT

Page 1: Acceptance Test-Driven Development: Mastering Agile Testing

MF AM�HalfͲday�Tutorial�11/11/2013�8:30�AM�

����

"Acceptance Test-Driven Development:

Mastering Agile Testing" ���

Presented by:

Nate Oster CodeSquads, LLC

�������

Brought�to�you�by:��

��

340�Corporate�Way,�Suite�300,�Orange�Park,�FL�32073�888Ͳ268Ͳ8770�ͼ�904Ͳ278Ͳ0524�ͼ�[email protected]�ͼ�www.sqe.com

Page 2: Acceptance Test-Driven Development: Mastering Agile Testing

Nate Oster CodeSquads, LLC

An agile player-coach and founder of CodeSquads, Nate Oster helps clients adopt lean and agile methods. Nate builds high-performance teams that adapt to change, embrace a pragmatic philosophy of continuous improvement, measure progress with new features, and deliver high-quality software that delights customers. As a coach, he inspires adopters with hands-on mentoring and simulations that provide a safe learning environment for new ideas. Nate promotes testing as a serious technical discipline. While Nate maintains a speaking schedule at software development conferences, he spends most of his time as a hands-on advisor to software product teams from startups to multinationals. Nate is easily defeated at all card games. Contact him at [email protected].

Page 3: Acceptance Test-Driven Development: Mastering Agile Testing

MASTERING AGILE TESTING

Nate OsterCodeSquads LLC

Page 4: Acceptance Test-Driven Development: Mastering Agile Testing

NATE OSTER

Agile Player-Coach & Founder, CodeSquads

Focused on adopting Lean & Agile methods

Mail: [email protected]

Twitter: nateoster

Voice: 703.930.4100

Page 5: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

LEARNING OBJECTIVES

Stop finding bugs after development!

Shift from tests as verification to tests as specification by learning to test first.

Simulate the feel of ATDD in a non-threatening way

Gain meaningful practice with table-based and plain-language formats for specifying intent.

Leave empowered to advocate ATDD with your own teams and managers!

Page 6: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

AGENDA

Agile Testing has limits

Simulation: Tests as Verification

ATDD Intro or How I Was Dragged Into Testing First

Simulation: Tests as Specification

Page 7: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

AGENDA

Specification by Example

Simulation: Examples using Tables

Simulation: Examples using Given-When-Then

Wrap-up: Action Planning

Page 8: Acceptance Test-Driven Development: Mastering Agile Testing

SIMULATION: TESTS AS VERIFICATION

Page 9: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

SIMULATION: TESTS AS VERIFICATION

Teams of 3 or 4

“Develop” an image by punching graph paper

“Test” your solution by fitting it over pegs

Satisfy your Customer!

Page 10: Acceptance Test-Driven Development: Mastering Agile Testing

ACCEPTANCE TEST-DRIVEN DEVELOPMENT

Stop testing bugs out. Start building quality in.

Page 11: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Anatomy(of(an(Itera-on(

Define(

Build( Test(

2(–(4(week(-mebox(

Define(

Build( Test(

Define(

Build( Test(

Define(

Build( Test(

Define(

Build( Test(

Define(

Build( Test(

Define(

Build( Test(

Define(

Build( Test(

Itera-on(Planning(2@4(hours(

Retrospec-ve(Itera-on(Dem

o(2@4(hours(2(hours(

a(few(days(

a(few(hours(

Itera-on(Planning…(

next(day…(

Feature(Team(

Nate%Oster,%“The%Agile%Challenge”%Workshop,%CodeSquads%LLC.%

Page 12: Acceptance Test-Driven Development: Mastering Agile Testing

SIMULATION: TESTS AS SPECIFICATION

Page 13: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

SIMULATION: TESTS AS SPECIFICATION

Start each story by outlining the acceptance criteria

Specify acceptance tests as concrete examples

If we don’t know when we’re done, then why are we starting?

Hypothesize the top 3 effects of this change

Page 14: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

RETROSPECTIVE: TESTS AS SPECIFICATION

Reflect:

Where your hypotheses correct?

Why or why not?

Prepare to Share:

Appoint a scribe

Share your results at your tables

List the top improvements

Page 15: Acceptance Test-Driven Development: Mastering Agile Testing

SPECIFICATION BY EXAMPLE

“An example would be helpful right about now.” - Brian Marick

Page 16: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Essential Incidental

Hat tip: Dale Emery

Page 17: Acceptance Test-Driven Development: Mastering Agile Testing

Technology-facing Tests

Business-facing Tests

Test

s th

at s

uppo

rt t

he T

eam

Tests that critique the product

“Agile Testing,” Lisa Crispin & Janet Gregory, used with permission (originally Brian Marick, 2006)

Exploratory Tests Usability Testing

UAT

Unit & Component Tests Performance Testing Security analysis

“-ility” tests

Acceptance Tests

Agile&Tes)ng&Quadrants&Mostly

Automated Mostly Manual

Automated Frameworks

Specialized Tools

Page 18: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

The$Test$Automa,on$Pyramid$

More business facing, realistic

Lower-cost Easier maintenance Faster feedback Acceptance Tests

(API Layer)

GUI

Unit & Component Tests

Exploratory /Manual

xUnit

FitNesse/ Cuke

Adapted from Mike Cohn (Automated Test Pyramid) & “Agile Testing”, Lisa Crispin & Janet Gregory..

Sn

Page 19: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

THE TEST AUTOMATION PYRAMID

Push tests as low as possible in the pyramid

Have tests focus on intent, not implementation

Team decides appropriate level for each test

Page 20: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

SOME TOOLS FOR EXECUTABLE SPECIFICATIONS

TOOL TECHNOLOGY SWEET SPOT

FitNesseJava (native)

.NET (plugin)

CucumberRuby (native)

Java (CucumberJVM).NET (plugin)

SpecFlow .NET (native)

Page 21: Acceptance Test-Driven Development: Mastering Agile Testing

SIMULATION: SPECIFICATION BY EXAMPLE

USING TABLES

Page 22: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

TABLE-BASED SPECIFICATIONS

(Re)-build a brokerage pricing engine

Start with the simplest scenarios using realistic examples

Be customer-focused!

Page 23: Acceptance Test-Driven Development: Mastering Agile Testing
Page 24: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Trade Source Ticker Buy/Sell Order Type Commission?

Internet GOOG Buy Limit $9.99

Internet GOOG Sell Limit $9.99

IVR GOOG Buy Market $34.99

Pricing.Stocks

[expected “$34.99”, actual “$9.99”]

Page 25: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

USE REASONABLE DEFAULTS

Eliminate duplication with conventions

Document the conventions with examples!

Trade Source Ticker Buy/Sell Order Type Commission?

Internet GOOG Buy Limit $9.99

Internet GOOG Sell Limit $9.99

IVR GOOG Buy Limit $34.99

IVR GOOG Sell Limit $34.99

Broker GOOG Buy Limit $44.99

Broker GOOG Sell Limit $44.99

Page 26: Acceptance Test-Driven Development: Mastering Agile Testing
Page 27: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

PREFER CONCRETE EXAMPLES OVER ABSTRACTIONS

It’s tempting to save time with abstract examples

We lose time maintaining “smart tests” that must complete the same calculations as the system.

Abstract Example

Concrete Examples

4% $40, $4000

Y, N $49.99, $0.00

‘Correct contents’ 3 spanish onions’

Page 28: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

OPERANDS != CLARITY

Operands and inequalities can actually obscure intent

Each operand conceals at least two test cases

Operand Concrete Examples

>180 179,180, 181

<= 180 179, 180

> $1,000 $1,001

Page 29: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Pricing. MutualFunds. NTF. ShortTermRedemption

No Transaction Fee Mutual Funds

180 days or less

No commission

$49.99 fee

Ticker Fund Type Load %

MNTF NTF N/A

MNLD No-Load N/A

MFEE Load 4% on Buy

Page 30: Acceptance Test-Driven Development: Mastering Agile Testing

WHAT IF I BUY TWICE IN 180 DAYS?

Page 31: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

TABLES MAY NOT BE EXPRESSIVE ENOUGH FOR SOME SCENARIOS

What if I buy the same fund more than once in 180 days?

“An example would be helpful right about now.” - Brian Marick

What if I sell when only part of the balance is 180 days old?

Page 32: Acceptance Test-Driven Development: Mastering Agile Testing

SIMULATION: SPECIFICATION BY EXAMPLE

USING TEST LINGOS**Credit to Patrick Wilson-Welsh and Dawn Cannon

for coining the term!

Page 33: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

GIVEN - Context

LINGO-BASEDSPECIFICATIONS

WHEN - Event

THEN - Outcome

Page 34: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

THINKING WITH GIVEN-WHEN-THEN

Scenario: Buying a no-load mutual fund charges a commission.

Given I do not own fund MNLD.When I buy $10,000 in fund MNLD,then the commission is $49.99 and the fee is $0.00.

When I buy fund MNLD,then the commission is $49.99.

Page 35: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Test FundsTicker Fund Type Load %

MNTF NTF N/A

MNLD No-Load N/A

MFEE Load 4% on Buy

Pricing. MutualFunds.Buy

Scenario: Buy a mutual fund.

Page 36: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Pricing. MutualFunds. NTF. ShortTermRedemption

No Transaction Fee Mutual Funds

180 days or less

No commission

$49.99 fee

Ticker Fund Type Load %

MNTF NTF N/A

MNLD No-Load N/A

MFEE Load 4% on Buy

Page 37: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

GIVEN-WHEN-THEN CAN BE MORE EXPRESSIVE THAN TABLES

What if I buy the same fund more than once in 180 days?

“An example would be helpful right about now.” - Brian Marick

What if I sell when only part of the balance is 180 days old?

Page 38: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Mutual Fund Short Term Redemptions

No transaction fee (NTF) funds held 180 days or less are subject to a Short Term Redemption Fee of $49.99.

Scenario: Part of sale held less than 180 days charges short term redemption fee.

Given I own 100 shares of MNTF for 181 days and I own 100 shares of MNTF for 179 daysWhen I sell 101 shares of MNTFThen I am charged a short term redemption fee of $49.99.

Scenario: ...

Page 39: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Scenario: Part of sale held less than 180 days charges short term redemption fee.

Given I own MNTF |shares| days held | | 100 | 181 | | 100 | 179 |

When I sell 101 sharesThen I am charged a short term redemption fee.

Page 40: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

NEW FEATURE: CONCIERGE LEVEL PRICING

Concierge Level pricing is a trial promotion.

It offers selected customers free internet trades if their total assets exceed $250,000 or if a trade is for more than $10,000.

Brainstorm acceptance tests for this feature using tables, given-when-then, or both. Your choice!

Page 41: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

Feature: Concierge pricing promotion.

Background:Given the concierge pricing promotion is active.

Scenario Outline: Buying in a selected account.Given a selected account with a balance of <total assets>,when I buy <trade amount> of <ticker> using source <trade source>, then the commission is <fee>.

Examples:| total assets | trade amount | ticker | trade source | fee || $499,999 | $10,001 | GOOG | internet | 0 || $500,001 | $1,000 | GOOG | internet | 0 || | | | | |

Page 42: Acceptance Test-Driven Development: Mastering Agile Testing

REVIEW

Page 43: Acceptance Test-Driven Development: Mastering Agile Testing

WRAP-UP: CREATE AN ACTION PLAN

Page 44: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

THE PROBLEM

Finding defects is expensive

Rework, Scrap, Delays

Feedback speed is limited

Page 45: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

GRASSROOTS FIRST STEPS

The Triad: Use specification by example at a whiteboard with a dev, analyst, and tester

Steel Thread: Try executable specifications for a few small bugs or stories

Plant Seeds: Host a brownbag and ask for support

Page 46: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

WRAP-UP: CREATE AN ACTION PLAN

What outcomes could specification by example improve on your teams?

What impediments to adopting spec by example do you anticipate?

How could you overcome these impediments?

What small experiments will quickly check your thinking about ATDD on your own teams?

Page 47: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

RESOURCES

[email protected]

Twitter: nateoster

Voice: 703.930.4100

Learn More:

Specification by Example (Gojko Adzic)

The Cucumber Book(Aslak Hellesoy)

Agile Testing(Lisa Crispin & Janet Gregory)

Experiment:

“Pull” in support through your Team’s retrospectives

People & Interactionsover Processes & Tools!

Reach Out:

Nate Oster

[email protected]

703-930-4100 (m)

Page 48: Acceptance Test-Driven Development: Mastering Agile Testing

©CodeSquads LLC “Mastering Agile Testing”

“Mastering+Agile+Tes/ng+Workshop”+copyright+©CodeSquads+LLC.++All#rights#reserved.These+materials+are+provided+under+license+to+individual+par/cipants.++Par/cipants+may+

not+reproduce,+alter,+or+build+upon+these+materials.++Par/cipants+may+not+reuse+these+

materials+for+training+purposes.++Slides+and+diagrams+that+are+specifically+iden/fied+as++

licensed+under+a+Crea/ve+Commons+(CCHBY+2.0+unported+license)+may+be+reproduced+

(without+modifica/on)+if+they+retain+the+aOribu/on+provided.+

MASTERING AGILE TESTING