Continuous Testing
Jared Richardson
Agile Artisans
@JaredRichardson
GrowsMethod.com
Who am I?
3
Cofounder of GROWS Methodology
Author Ship It! and Career 2.0
Screencast editor PragProg.com
2nd public signatory of the Agile Manifesto
Started AgileRTP in 2007
Coach
AgileArtisans.com
Jared Richardson
Who are you?
What’s up with the material?
Major rewrite
Introduction
Slides on USB
On Slideshare.com
Provided to conference as well
Who’s a User?
Already using continuous integration?
Continuous deployment?
Which tools?
Test first?
What would you say you do
here?
Roles?
Responsibilities?
Why are you here?
What are your tests for this session?
Objectives
Understand Continuous Feedback in context of a healthy SDLC
Understand the Continuous Paradigm
Understand an end-to-end Continuous workflow
Understand how to scale your efforts
Outline
GROWS Methodology
Continuous paradigm
Battleship!
Continuous Integration (benefits & workflow)
Continuous Testing (benefits & workflow)
Miscellaneous tips & tricks
Breaks
Halfway (90 minutes)?
Each hour ?
Speak up!
SDLC
Idea
Verifies
Use or
delete
Implements
Software Development Life Cycle
wikipedia.org/wiki/Waterfall_model#/media/File:Waterfall_model.svg
Traditional Approach
Requirements
Write Code
The Traditional Approach
Demo
Rewrite (60%)
“Discussion”
The architects
generate a
document and
hand it off
An isolated event,
primarily worked by
the customer proxy
Arch
Code like mad!
We’re starting
late!
Not what we meant!
Wrong arch
Ignored my docs
etc
so on
Demo
Write Code
Requirements
A More Agile Approach
Before
significant time
and $$ is
invested
Discuss
Include the
Golden Triad
Dev QA
Customer
Rewrite
Demo
Write Code
Architecture
Proof of Concept
Requirements Arch
Why Feedback?
Feedback is good for budgets
Cheaper
Faster
More accurate
Lower risk
flickr.com/photos/alancleaver/4293345631
To Err is Human
What’s your recovery plan?
Experimentation
Learn about software by writing software
Can’t study your way into experience
Like riding a bike
Create feedback loops
flickr.com/photos/schwar/6801765768
Requirements
Rewrite
Discuss
Node.js
Bootstrap
Angular.js
Pick one
SOA
Monolithic
Peer to peer
Pick one
Developers
disagree on
which architecture
is best
Continue until you can demo
Developers
disagree on
which Javascript
toolkit is best
Demo
Revise
Rewrite
Adjust
Frequent demos discover communication failures early
Discuss
Intentional
Experimentation
Study
Experiment
Learn
Decide! Learn
Learn Decide!
Two Paths
GROWS Methodology
Directed Empiricism
Why Bother?
https://www.mountaingoatsoftware.com/blog/agile-succeeds-three-times-more-often-than-waterfall
Acceptance
We’re not very good
We’re going to mess up
Mistakes are inevitable
How do we recover?
Continuous
Paradigm
Experimentation
We’re not very good
We’re going to mess up
Mistakes are inevitable
How do we recover?
STICK Experiments
Short
Time boxed
Informative
Concrete
Key
Specific
flickr.com/photos/peterpearson/1062279922
Automated Tests
Answer Questions
Is this done?
Does it still work?
Does it work somewhere besides my machine?
This is what I’m asking you to write.
Everything is checked in.
flickr.com/photos/bobowen/4501875907
Product or system
flickr.com/photos/30691679@N07/3808395213
Module/
Sub System
flickr.com/photos/kevino/1438502858
Class
Feedback Loops are
Fractal
flickr.com/photos/dancentury/4579906149
Agility Is...
Tighter Feedback Loops
Which Level?
35
36
Days
Iterations
Months
Quarters
Years
Optional
Optional
C*/Board
37
VP
38
Director Level
39
Management
Level
40
Developer
Level
41
flickr.com/photos/89228431@N06/11348332905
Minimize Our Dark Times
Code Change
Validation
Fast feedback
leads to fast
fixes
flickr.com/photos/bogenfreund/556656621
Different Levels
Manual acceptance tests
Unit tests
Continuous Testing
Different Levels
Good at the bottom
Great at the top
Ignore the middle
Continuous Feedback
Continuous Integration
Continuous Delivery
Continuous Testing
Continuous Monitoring
Continuous deployment is controversial.
Most people ... think I’m advocating
low-quality code
or an undisciplined
cowboy-coding
development process.
Eric Ries
radar.oreilly.com/2009/03/continuous-deployment-5-eas.html
Language is a Tool
Use it
Exercise
How long is your SDLC (idea to verification)?
What are your SDLC feedback bottlenecks?
Write down 3 worst bottlenecks
Gather into groups of 5 to 7
Share and discuss
Keep your list!
Take ten minutes
Continuous Integration
Continuous Integration
Watch Code
Build product
Run tests
Publish results
Pros
Fast feedback
Known state
Easily consumed history
Shines a light
52
Cons
Slows you down
Nags you after every code change
Exposes problems
Shares issues
Forces you to deal with problems
Smoke alarm
53flickr.com/photos/117168856@N06/12486837493
54
Work
Time
Perception of Problem Accumulation
55
Work
Time
Actual Problem Accumulation
56
Work
Time
Continuous Problem Resolution
Sidebar: How We Learn
Dreyfus Model of Skills Acquisition
57
58
Start
Familiar
Working
Smooth
Teaching
Dreyfus
Model
of
Skills
Acquisition
Steps
Recipes
Intuition
Stuck
Principles
Key Points
Skills don’t map
59dilbert.com/strip/1990-09-13
Key Points
Beginners need steps
60
Steps
1. Use source code management (SCM)
2. Check in ~everything~
3. Automate the build (script)
4. Acquire a build environment (isolated)
5. Install build tools (dev tools)
61
Java Tooling
Publish results
Continuous Integration Servers
Many
Jenkins
Cruise Control
Bamboo
Pulse
TFS
63
Jenkins
Open source
Established
Split from Hudson
Java application
Any application server
Self contained
64
Example
Publish results
javac (Oracle & IBM)
message broker
etc
ws ejb deploy
message broker tools
sshexec (to scripts)
JUnit
HP's UFT
Selenium
Cucumber
Web page
RSS
Email
Common Scenarios
66
Dependent Builds
My build depends on another team’s build
No problem
We’ll trigger your build based on their results
67
Dependent Builds
Services
Client/GUI
Data Layer
Complicated Dependencies
Our software is too complicated for CI
69
flickr.com/photos/chaoticmind75/16169722270/
Dependent Builds
Data Layer
Data Services
Rich Client
Common Libs
Web Portal
Biz Services
What’s Big?
3,000 developers
300 major projects
All related
Platform to UI
Multiple branches
71
Common Integration Build
72
Chained Continuous Integration
Team 1 Team 2 Team 3
Integration
build
Multiple Platforms
74
Platform Testing
Team 1 Team 3Team 2 Team 4 Team 5
Integration Build
Platform1 Plat 3Plat 2 Plat 4 Plat 5
Battleship!
Each player
has a board
flickr.com/photos/spookyamd/6333317567
flickr.com/photos/jking89/1363983490
Place your fleet
Drop your bombs
Two Ways
to Play
flickr.com/photos/compacflt/22797421725
flickr.com/photos/bz3rk/2436165683
Use all your ammo quickly
Use ammo one shot at a time
Round 1
Start a timer
Place your fleet
Use all your “ammo”
Check with your opponent
Record hits/misses/time
Play twice
Round 2
Start a timer
Place your fleet
Fire 1 round
Check with your opponent
Continue until out of ammo
Record hits/misses/time
Ships & Ammo
1 Sub (2 dot ship)
2 Destroyers (3 dots ships)
1 Battleship (4 dot ship)
1 Aircraft carrier (5 dot ship)
35 rounds to fire
Results
Which way is faster?
Which spends less “budget”?
Which way is more effective?
Which way do you prefer?
Feedback
Faster with feedback?
Slower with feedback?
Is slower bad?
Efficient or Effective
A B C D E F G H I J
1
2
3
4
5
6
7
8
9
10
Opponent’s Fleet
A B C D E F G H I J
1
2
3
4
5
6
7
8
9
10
My Fleet
A B C D E F G H I J
1
2
3
4
5
6
7
8
9
10
Opponent’s Fleet
A B C D E F G H I J
1
2
3
4
5
6
7
8
9
10
My Fleet
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
A B C D E F G H I
1
2
3
4
5
6
7
8
9
Time Shots Misses Hits Sinks % hits % sinks
1st All at once
2nd All at once
3rd Interactive
4th Interactive
Battleship! An exercise by Tony
Brill1 2 3 4
Continuous Testing
Continuous Integration
Watch Code
Build product
Run tests
Publish results
Continuous Testing
Watch CI
Deploy product
Integration
tests
Publish results
Continuous Testing
CI CT
Compile &
unit test
Deploy &
integration test
Watch
Build
Unit Tests
Publish
Continuous
Integration
AgileArtisans.com
Watch
Build
Unit Tests
Deploy
to Dev
Integration
Tests
First
Look
Continuous
Testing
AgileArtisans.com
SCMDevelopers
Watch
Build
Unit Tests
Deploy
to Dev
Integration
Tests
First
Look
Continuous
Testing
On
Demand
Deploy
to QA
Manual
Testing
AgileArtisans.com
Continuous Testing
Build in CI (compile & unit tests)
Deploy to dev (staging)
Run integration tests
What does this tell us?
If it works
How?
By keeping fast feedback fast
Providing slow feedback slowly
Don’t tie fast feedback to slow feedback
Fast vs Slow
“Fast”
Integration
Tests
Compiles
& Unit Tests
Slow
Integration
Tests
5-10 minutes
30 to 60
4 to 8 hours
What's this look like?
Continuous Testing
CI CT
Compile &
unit test
Deploy &
integration test
Multi Platform Deploys
CI
CD Win7
CD Linux
CD OS X
Exercise
Remember your SDLC bottlenecks?
What could continuous integration solve?
What could continuous testing solve?
Regroup with your team and discuss
Bring your top 3 solutions
99
As We Explore a
Continuous World...
10
0
What Concepts Emerge?
10
1
Nuke and Pave
Reset (completely)
Start over
Completely Scripted
10
2
Binaries
Nuke & Pave
Delete
Recompile
Deploy
Use
10
3
flickr.com/photos/x-ray_delta_one/4152356464
Data
Nuke & Pave
Delete schema
Drop tables
Recreate
Restock
Rails
Liquibase
10
4
flickr.com/photos/x-ray_delta_one/4152356464
Rails ActiveRecord
CREATE TABLE products (
id int(11) NOT NULL auto_increment,
name varchar(255),
PRIMARY KEY (id)
);
10
5
Rails ActiveRecord
change_table :card_deck do |table|
tablet.remove :description, :name
tablet.string :first_name
tablet.index :part_number
tablet.rename :list_name, :last_name
end
10
6
Rails ActiveRecord
rake db:migrate
rake db:migrate VERSION=0
rake db:reset
10
7
ActiveRecord
rake db:reset
Drops schema
Recreates schema
10
8
Operating System
Nuke & Pave
Virtualize
Recreate
10
9
flickr.com/photos/x-ray_delta_one/4152356464
Steps for a New OS
Install VirtualBox
Install Vagrant
vagrant init hashicorp/precise32
vagrant up
11
0
Benefits
Scriptable
Reproducible environment
Solid results
Fast results
Repeatable results
When?
Day one
Easiest
“If you don’t do it on Day One,
you probably won’t”
Andy Hunt
113andy.pragprog.com
Easy?
No
Difficult
Necessary
Costs Move to Zero
Once scripted…
What changes?
How do We Improve Our
Feedback Loops?
Developers
Devs write
code
normally
SCM
Code is shared
via a source
code
management
tool
Continuous
Testing
Providing
immediate
feedback and a
shared
environment
for a QA “First
Look”
Triggered
Deploy
to QA
QA team
members
trigger this
deploy
Manual
Testing
A stable
environment for
manual and
exploratory testing
SCMDevelopers
Watch
Build
Unit Tests
Deploy
to Dev
Integration
Tests
First
Look
Continuous
Testing
On
Demand
Deploy
to QA
Manual
Testing
Rapid feedback
Pair Dev & QA
First Look
• QA can see what’s been coded immediately
• Differences in opinions can be discussed quickly
• Fewer problems during the larger testing cycles
• Keeps QA & Dev working together as partners
• Minimizes feedback for the previous iteration
• Faster feedback for QA
Continuous Testing
• Includes QA in the continuous feedback cycle
• Retains a traditional QA stable testing environment
• Dev & QA should both review all tests (unit & int.)
• QA requests trigger the QA env. deployment
Alternatives
flickr.com/photos/lightsinthedark/5810724330/
Work in a vacuum
Builds
Deploys
Tests
flickr.com/photos/pmillera4/931792447
4
Ruthlessly Automate
Be Lazy!
You have builds scripted
CI servers running
Tests written
Things deploy
What else can you do?
flickr.com/photos/ofernandezberrios/2720567252
Dev
Environments
QA
Staging
Prod
5 minutes
Integration
Tests
8:15am
8:20am
8:50am
8:25am
8:30am
8:35am
8:40am
8:45am
Traditionally…
Someone needs the app
Notices it’s down
URGENT!
FIX!
Fire drill
flickr.com/photos/kaibara/5332191131
Detect Problems
Before it’s urgent
Detect
Notify
Fix
Wait
5 minutes
Integration
Tests
Continuous
Monitoring
Notify
Feedback Loops
Identify
Reduce
Minutes
Not days
Never weeks
Months
flickr.com/photos/parkstreetparrot/9764446493
Steps
flickr.com/photos/jalalspages/842122500
Steps
Continuous Integration (aka compiles)
flickr.com/photos/jalalspages/842122500
Steps
Continuous Integration (aka compiles)
Test coverage numbers (aka unit tests)
flickr.com/photos/jalalspages/842122500
Steps
Continuous Integration (aka compiles)
Test coverage numbers (aka unit tests)
Continuous deployment (aka deploys to dev/test)
flickr.com/photos/jalalspages/842122500
Steps
Continuous Integration (aka compiles)
Test coverage numbers (aka unit tests)
Continuous deployment (aka deploys to dev/test)
Continuous testing (aka integration tests)
flickr.com/photos/jalalspages/842122500
Steps
Continuous Integration (aka compiles)
Test coverage numbers (aka unit tests)
Continuous deployment (aka deploys to dev/test)
Continuous testing (aka integration tests)
Continuous monitoring (test against environs)
flickr.com/photos/jalalspages/842122500
Culture Change
Fundamental change in development
Steps
Automate builds
Continuous Integration
Add unit tests
Automate deployments
Continuous Delivery
Add integration tests
flickr.com/photos/untitlism/25474234
65
Your Move
Exercise
At lunch
Continuous Testing
Two 3x5 cards
3 reasons for
3 barriers to adoption
Groups of 5 to 7
Brainstorm on solutions
flickr.com/photos/curtisperry/6119618990
Exercise
Useful or not...
Will you pursue or not...
Continuous Integration
Continuous Testing
Continuous Monitoring
Test automation
How will these ideas help or hurt your org?
Write down your answers and pass them up
GrowsMethod.com
AgileArtisans.com
jared@GrowsMethod.com
An Addendum
Test Automation
Unit tests
Acceptance Tests
Unit Tests
One class
One method
Fast
Illuminating
Integration Tests
High level
Lots of coverage
No detail
Continuous Feedback
Large amounts of code
Small amounts of change
Tests run after every change
Requires frequent code checkins
What's Better?
Unit or Integration?
150
Best Is...
Automated
Reliable
Frequently executed
151
Test Lifecycle
Set up state
Use product
Verify results
(Clean up)
152
Set Your Teams Up
Builds work
Functionality works
Biggest risk?
Requirements
Developers Testers
Customers
The Team
Grid Driven Development
Remove technical barriers
Everyone speaks “Excel”
Testing Strategies
Test First is best
Defect Driven Testing
Blitzkrieg Testing
Tips
Open standards...
Junit or Junit compatible
Avoid vendor lock in
Glue tools
Time matters....
Fast servers
Incremental change
Script Tips
Save scripts in source code management
Modular
Basic encapsulation
One target => One function
Script Targets
all depends_on clean, compile, test-unit
clean # deletes build artifacts
compile # builds the product (Ruby?)
test-unit # run your tests
deploy_locally # to your dev environment
deploy_dev (?) # to a shared dev environment
test-integration # run your integration tests
Resources
JUnit JUnit.org
Jenkins Jenkins-ci.org
BDD Dannorth.net/introducing-bdd
Cucumber Cukes.info
Continuous Deployment en.wikipedia.org/wiki/Continuous_delivery
Devops Resources
VagrantUp.com
GetChef.com/chef
PuppetLabs.com
Ansible.com
VirtualBox.org
Data Resources
Guides.RubyOnRails.org/active_record_basics.html
Liquibase.org
FlywayDB.org
Additional Content
Material for you to review later…
Release Planning
Releases contain features
How many are ready to ship?
164
Releases contain features
165
Team
Release
Date
Release
Theme
#
Features
#
Stories
Stories
Complete
%
Done
1
2
3
Releases contain features
Team Release Features Stories
Stories
Complete
% Done
A 7/1 25 392 17 0.23
B 7/15 13 208 104 0.5
C 7/12 96 2,400 150 0.16
D 12/30 476 ?? 234 ?
Release date
Burn Up Chart
167
Time
Features
Features in
the release
Required
rate of work
Will we hit our date?
168
Time
Features
ACTUAL
rate of work
Burn Up Chart
169
Time
Features
ACTUAL
rate of work
Feature Creep
170
Time
Features
ACTUAL
rate of work
Observe Progress
On track
Behind
Unrealistic
171
The Solution
Reduce features
DO NOT focus on increased work
172
Good or Not?
173
Time
Features
ACTUAL
rate of work
What’s the Fix?
174
Time
Features
How do I
make the team
work harder?
175
Longer
Hours
Work Faster!Even
Later
More
Mistakes
Lots of
Debugger
Time
What’s the Fix?
176
Time
Features
What’s the Fix?
177
Time
Features
What’s the Fix?
178
Time
Features
What Happens to Overloaded Planes?
179
flickr.com/photos/jameski/5322886899

Continuous Testing in Vegas