Top Banner
1 Making Test Automation Work in Agile Projects Belgium Testing Days 2012 Lisa Crispin With Material from Janet Gregory
83

Belgium Testing Days - Making Test Automation Work in Agile Projects

Nov 01, 2014

Download

Technology

lisacrispin

Slides from tutorial. Note that the most important part of the tutorial is the exercises, and I can't capture that in the slide deck. Please do not use these for public paid courses, I'm tired of our stuff being ripped off for agile testing classes.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Belgium Testing Days - Making Test Automation Work in Agile Projects

1

Making Test

Automation Work in

Agile Projects

Belgium Testing Days 2012

Lisa Crispin

With Material from Janet Gregory

Page 2: Belgium Testing Days - Making Test Automation Work in Agile Projects

2

Introductions: Experience, Goals

Form groups: New to automation One to two years experience w/ automation More than two years experience

Talk with at least two other people Tell each other your learning goals for today Note the most interesting one you hear

Page 3: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 3

About me…

Programmer, tester, agile team member

Page 4: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 4

Introduction - You

Main role on team? Programming, automation experience? Using agile approach? What have you automated? (Test,

CI,deployment...)

Page 5: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 5

Takeaways

Foundation for successful test automation “Whole Team” approach What/when to automate Identifying, overcoming barriers Choosing, implementing tools First steps We won’t do any hands-on automation, but will demo

some examples

Page 6: Belgium Testing Days - Making Test Automation Work in Agile Projects

6

Exercise: Your Learning Goals

Write one interesting learning goal you heard from another participant at the start of the class on a sticky note. Write your number one learning goal for

today on a sticky note. Put the sticky notes on your table group

“learning goals” sheet Group similar ones together

Page 7: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 7

Let‟s start by defining “agile”

Agile teams:

Deliver business value

frequently

at a sustainable pace

while adapting to the changing

needs of the business

Source: Elisabeth Hendrickson

Page 8: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 8

The key is “sustainable pace”

Technical debt slows us down

Page 9: Belgium Testing Days - Making Test Automation Work in Agile Projects

The Death

Spiral

Page 10: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin

High technical debt +

insufficient automation = even

less time

Page 11: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 11

Barriers to Test Automation

What‟s holding you back?

Page 12: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 12

Exercise: Your barriers

Individually and silently – write one barrier hindering your team per sticky note

Put these on the “impediments” wall chart for your table group

Talk to your fellow group members – do you see any patterns?

Page 13: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 13

Questions?

Page 14: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 14

The Whole-Team Approach

Automated tests are code Respecting the tests Collaborating Commitment to quality Return on investment

Page 15: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 15

Automated tests are code

public class CalculatorFixture extends

ColumnFixture {

public String startDate;

public String endDate;

public double startBalance;

public double endBalance;

public String irrTarget;

private Calculator calculator = new

Calculator();

private Double irr;

Page 16: Belgium Testing Days - Making Test Automation Work in Agile Projects

Test code deserves the same respect as

production code! (Rodney

Dangerfield, a

comedian whose

tag line was “I

don’t get no

respect… )

Page 17: Belgium Testing Days - Making Test Automation Work in Agile Projects

Source: Gojko Adzic, StarEast 2011 keynote

Page 18: Belgium Testing Days - Making Test Automation Work in Agile Projects

Source: Gojko Adzic, StarEast 2011 keynote

Page 19: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 19

Testers are especially good at…

Eliciting examples

Turning them into tests

Ensuring the right testing

gets done

Exploratory testing

Page 20: Belgium Testing Days - Making Test Automation Work in Agile Projects

20

Give testers time to do what we do best

How?

Page 21: Belgium Testing Days - Making Test Automation Work in Agile Projects

21

The Whole-Team Approach

Page 22: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 22

Experiment: Iteration 1

Pair up: one will be tester, one programmer

Sit back to back so you face away from each other

Tester gets a drawing which needs to be replicated

Tester tells the programmer what to draw, all at one time.

Programmer draws the shapes based on what the tester explained.

No talking during „coding‟!

Tester “tests” the drawing, reports “bugs” on index cards

Programmer fixes the “bugs”

How long did it take? Will the customer be happy?

Page 23: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 23

Experiment: Iteration 2

Collaborate!

Tester tells programmer what to draw, watches the programmer draw, answers questions, points out „defects‟ for programmer to fix immediately

(Don‟t show the programmer the drawing, that makes it too easy, we‟re trying to simulate real coding)

How long did it take? Will the customer be happy?

Thanks to the members of the agile-games group and Kane Mar for ideas & pictures for this game

Page 24: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 24

Ways to collaborate

Pair

Page 25: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 25

Team responsibility

Automate all regression tests

Page 26: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 26

Page 27: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 27

Commitment to quality What‟s your team‟s commitment? The best possible software product?

Page 28: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 28

Learn

Experiment

Meaningful

Commitmen

t

Page 29: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin

Under-commit

Plan less work than you think you can do

Including all test automation

Page 30: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 30

Learn to write maintainable tests

Get over the “hump of pain”

From Gerard Meszaros’ XUnit Test Patterns

Page 31: Belgium Testing Days - Making Test Automation Work in Agile Projects

Whole-team software development

31

Create a user story

Write Customer

(Q2) Tests

Start thinking how to code

Expand tests – Story Tests

Automate Q2 Tests

Exploratory testing

TDD

Customer User

Acceptance

Product owner Product owner/ Tester Tester Tester/Programmer Programmer

Pair, “Show

Me”

Page 32: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin

Exercise

•Think of an experiment to get your

whole team engaged in automating

tests

•Share with your table group •Pick two to share with the class

Page 33: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 33

Getting Over the Hump

The test automation pyramid The agile testing quadrants What should be automated What shouldn't Difficult areas

Page 34: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 34

Test Automation Pyramid

Page 35: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 35

Agile Testing Quadrants

Page 36: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 36

Shared Understanding

Start with tests Collaborate

Page 37: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 37

What Should We Automate?

Quadrant 1 tests

Unit, component, TDD

Quadrant 2 tests

API, service-level

Quadrant 4 tests

Load, performance, stress

Quadrant 3 tests?

Leverage automation where useful

Page 38: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 38

What Shouldn‟t We Automate?

Quadrant 2 tests

Wizard of Oz, prototyping

Quadrant 3 tests

Usability, UAT, ET

Tests that will never fail?

Assess risk

ROI not enough

One-off tests

Page 39: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 39

Where Should We Be Careful?

GUI tests

Watch ROI

End-to-End tests

Push testing down to lowest level

Remember the Pyramid

Page 40: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 40

Hard to Automate?

Legacy code

Hard to automate, or just lack of skill?

“Working Effectively with Legacy Code” – Feathers

“Strangling” – Fowler, Thomas

Page 41: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 41

Exercise: Low-Hanging Fruit

Page 42: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 42

Agile Automation Strategy

What hurts the most

Layered approach

Applying agile principles

Small chunks/thin slices

Smart test design

Choosing the right tools

Page 43: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 43

What Hurts the Most

Use retrospectives

Keep an impediment backlog

Page 44: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 44

Multi-Layered Approach

Example: Learn TDD at unit level Automate GUI smoke tests

Page 45: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 45

Simplicity

Address one or two needs at a time

Understand the problem first

Try simplest approach first

Work in small chunks, thin slices

Incremental & iterative

Page 46: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 46

Automate a Slice at a Time

Example: 4-step UI to validate, upload profit sharing contribution data

• Thread 1: All four pages with navigation

• Thread 2: Select year, enter description on page 1, display on page 2, browse and upload file on page 2

• Thread 3: Validate data in file, display on page 3

• Thread 4: Persist data, display „success‟ message on page 4

Page 47: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 47

Thin Slice Example

Page 48: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 48

Exercise: Thin Slices

Here‟s our user story:

As an internet shopper, I want to create an

account so that I do not have to enter my address

and billing information each time I make a

purchase

Draw a mind map for this story on a big sheet of

paper

Identify a basic end-to-end slice of functionality

that can be coded, tested, and automated.

If you have time, identify additional slices.

Page 49: Belgium Testing Days - Making Test Automation Work in Agile Projects

49

Test Design Patterns/Principles Code design patterns One clear purpose Don‟t Repeat Yourself

Page 50: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 50

Demo

Page 51: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 51

Iterative Feedback

Spike two different approaches Pick one to try for N # of iterations Use retrospectives to evaluate

Page 52: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 52

Learn by Doing

Courage – don‟t be afraid to fail Production code practices for test code Incremental, thin slices Experiment

Page 53: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 53

Questions About Automation Strategy?

Page 54: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 54

Choosing Tools

Team effort Time Requirements Focus on goals, problems, not tools. Experiment

Page 55: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 55

Understand the Purpose

Who‟s using the tests? What for? What‟s being automated? Existing tools, environment Who‟s doing what for automating?

Page 56: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 56

What Fits Your Situation • Existing skills • Language of application under test • Collaboration needs • What‟s being automated • Life span, future use of tests

Page 57: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 57

Test Drivers/Frameworks

Automation layer Fit for everyone on team Try out more than one Let‟s look at more examples

Page 58: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 58

Where To Find Tools

www.softwareqatest.com/qattls1.html

www.testingfaqs.org

www.opensourcetesting.org

awta.wikispaces.com/2009ToolsList

groups.yahoo.com/group/agile-testing

http://bit.ly/AgileTestTools - aa-ftt spreadsheet

Page 59: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 59

Example: My Team‟s Tool Choices

• IntelliJ Idea

• Jenkins, ant, Maven

• JUnit

• FitNesse

• Canoo WebTest

• Watir

• JMeter

• Selenium 2.0 / WebDriver with Geb framework

Page 60: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 60

Exercise: Tools

Page 61: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 61

Making Test Automation Work

Time to do it right

Learning culture

Testable architecture

Test data

Managing tests

Page 62: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 62

Time To Do It Right

Limit scope, don‟t over-commit

Write automation task cards

Quality must be team goal

Long-term, will let you go faster

Page 63: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 63

Learning Culture

OK to make mistakes

Lots of small experiments

Slack

Evolve right design

Page 64: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 64

Testable Architecture

• Layered architecture • eg. UI, business logic, data access

• Ports and Adapters pattern • App can work without UI or database

• Ports accept outside events

• Adapters convert for human or automated

users

Page 65: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 65

Test Data

Avoid database access when possible

Setup/Teardown Independent, rerunnable tests

Canonical data Refresh before each test run

Customizable data for ET

Production-like data Get customers to provide example data

Page 66: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 66

Managing Automated Tests

Tests as Documentation

Continuous Integration

Reporting results

Metrics

Page 67: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 67

Tests as Documentation

Understandable

Who will really use them?

Once passing, must always pass

Page 68: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 68

Any Example Can Become a Test

Page 69: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 69

Given/Then/When Example

Scenario: Valid name search returns results

GIVEN that Kant is a supervisor with employees

AND Kant has an employee named Smith

WHEN Kant navigates to the employee name

search page

AND enters the value “S”

THEN Kant will see a search result that includes

Smith

Page 70: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 70

Continuous integration/testing…

…short feedback loop

Page 71: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 71

Keep tests passing

Stop the line to fix problems

Page 72: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 72

Test Management Tools

Manage tests, code together

Some tools have own management

What problem are you trying to solve?

Page 73: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 73

Exercise: Tests as Documentation

Page 74: Belgium Testing Days - Making Test Automation Work in Agile Projects

74

Key Success Factors

Whole Team Approach

Thin Slices

Short Feedback Loops

Experiments

Specification by Example

Page 75: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 75

Exercise: Breaking Barriers

Page 76: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 76

Remember

It‟s a team problem!

Tackle automation problems with diversity

Try small experiments

Baby steps – start simple

Page 77: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 77

Questions? “Aha” Moments?

Page 78: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 78

Agile Testing: A Practical Guide for Testers and Agile

Teams

By Lisa Crispin and Janet Gregory

www.agiletester.ca

Page 79: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 79

Experiences of Test Automation

Dorothy Graham and Mark Fewster

Page 80: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 80

Beautiful Testing: Leading Professionals Reveal How

They Improve Software

Edited by Tim Riley, Adam Goucher

Includes chapter by yours truly

Page 81: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 81

Test Patterns

Xunit Test Patterns: Refactoring Test Code

By Gerard Meszaros

Page 82: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin Copyright 2008 Janet Gregory, DragonFire

82

Specification by Example

How successful teams deliver the right

software

Gojko Adzic

Case studies from > 50 teams

Page 83: Belgium Testing Days - Making Test Automation Work in Agile Projects

Copyright 2012: Lisa Crispin 83

Agile Test Automation Resources

dhemery.com/pdf/writing_maintainable_automated_accep

tance_tests.pdf

lisacrispin.com janetgregory.ca gokjo.net exampler.com [email protected] testobsessed.com testingreflections.com pairwith.us