46
Copyright © 2013, AgileFAQs. All Rights Reserved. Inverting The Testing Pyramid Naresh Jain [email protected] @nashjain http://nareshjain.com

Inverting The Testing Pyramid

Embed Size (px)

DESCRIPTION

As more and more companies are moving to the Cloud, they want their latest, greatest software features to be available to their users as quickly as they are built. However there are several issues blocking them from moving ahead. One key issue is the massive amount of time it takes for someone to certify that the new feature is indeed working as expected and also to assure that the rest of the features will continuing to work. In spite of this long waiting cycle, we still cannot assure that our software will not have any issues. In fact, many times our assumptions about the user's needs or behavior might itself be wrong. But this long testing cycle only helps us validate that our assumptions works as assumed. How can we break out of this rut & get thin slices of our features in front of our users to validate our assumptions early? Most software organizations today suffer from what I call, the "Inverted Testing Pyramid" problem. They spend maximum time and effort manually checking software. Some invest in automation, but mostly building slow, complex, fragile end-to-end GUI test. Very little effort is spent on building a solid foundation of unit & acceptance tests. This over-investment in end-to-end tests is a slippery slope. Once you start on this path, you end up investing even more time & effort on testing which gives you diminishing returns. In this session Naresh Jain will explain the key misconceptions that has lead to the inverted testing pyramid approach being massively adopted, main drawbacks of this approach and how to turn your organization around to get the right testing pyramid.

Citation preview

Page 1: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Inverting The Testing Pyramid

Naresh [email protected]

@nashjain http://nareshjain.com

Page 2: Inverting The Testing Pyramid

Plan

Design

Distribute

Work in Isolation

Integrate

Hap

pine

ss/E

xcite

men

t

Time/Money/Opportunity Cost

Back in the Stone-age

Page 3: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Last Minute Integration Surprises

Page 4: Inverting The Testing Pyramid

BAD things were visible too Late...

Page 5: Inverting The Testing Pyramid

Birth of CI

Page 6: Inverting The Testing Pyramid
Page 7: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

CI Helped Us Learn That... Integrating Early, Integrating Often

Feedback Quality

Delivery Time Wastage

Collaboration

Page 8: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Key Questions

Are we building the right product?

Are we building the product right?

Business Facing

Technology/Implementation Facing

Page 9: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Brian Marick’s Test Categorization

Business Facing

Technology/Implementation Facing

Supp

orts

Pro

gram

min

gC

ritique product

Before/While Coding Post Coding

Page 10: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

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

Page 11: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

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

Page 12: Inverting The Testing Pyramid

Lean-Start-up CommunityTried something quite disruptive...

Page 13: Inverting The Testing Pyramid
Page 14: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Continuous Deployment

Page 15: Inverting The Testing Pyramid
Page 16: Inverting The Testing Pyramid

But...

Page 17: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Software Testing Ice-cream Cone

Unit Tests

IntegrationTests

End-to-EndGUI Tests 10-20%

5-10%

1-5%

Manual Checking

Page 18: Inverting The Testing Pyramid

Commercial Break!

Page 19: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Page 20: Inverting The Testing Pyramid

Tech Talks!

Page 21: Inverting The Testing Pyramid
Page 22: Inverting The Testing Pyramid
Page 23: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Inverting the Testing Pyramid

Unit Tests

IntegrationTests

End-to-EndGUI Tests 80-90%

5-15%

1-5%

Typical testing strategies lead to an inverted testing pyramid...

Manual Checking

Page 24: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Inverting the Testing Pyramid

Unit Tests

Biz Logic Acceptance Tests

Integration Test

Workflow Tests

End to End Flow Tests

GUITests

1%

70%

10%

9%

6%

4%

PerformanceTests

SecurityTests

This is the need of the hours...

One Layer Below GUI

Page 25: Inverting The Testing Pyramid
Page 26: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Number of End-to-End TestsT1 T2 T3

DB

Classes

Method Calls

8 9 11

70 Complex, Fragile End-to-End Tests vs.

61 Unit tests + 8 End-to-End Tests

Page 27: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Best ROI for Testing

End to End

API

Modules

Unit

0 25 50 75 100

Impact Effort

90% 10%

70% 30%

65% 35%

90%10%

Laye

rs

Value

Page 28: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Types of Tests in the Testing Pyramid

Unit Tests

AcceptanceTests

GUITests

Small Agile Projects with Single Team

Unit Tests

Biz Logic Acceptance Tests

Integration Test

Workflow Tests

End to End Flow Tests

GUITests

1%

70%

10%

9%

6%

4%

PerformanceTests

SecurityTests

Large Scale Agile Projects with Global Teams

One Layer Below GUI

Page 29: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Types of Tests for Large Agile ProjectType Tool Who When Level Objective

Unit TestsxUnit, Mockito/Moq, Jasmine, HSqlDB, Jumble

Developers During the Iteration, while coding Class

Each class functions correctly in isolation. The UI components (including JS) can also be unit tested in isolation.

Biz Logic Acceptance Tests

Cucumber (some may need Lisa)JMeter/LoadRunner

TechBAs + Developers + Testers (QA)

Acceptance Criteria are defined before Iteration starts. Acceptance Tests are written during Iteration, before coding

Work-steam specific business functionality (At component level)

From a business logic point of view, the functionality is implemented correctly. Works in isolation with other work-streams/modules.Also good point to do some basic performance testing.

Integration Test

xUnit + LisaDevelopers + Testers (QA) + TechBAs

Contracts are defined before Iteration, tests are implemented during the Iteration

Between dependencies (work-streams, upstream/down-stream systems, 3rd Party)

2 Components can communicate with each other correctly. Best suited for negative path testing. Should not test any functional aspects of the application.

Workflow Tests

Cucumber + LisaSMEs + TechBAs + UX + Developers + Arch + Testers (QA + UAT)

When a theme is picked (functional group of Iterations)

Across a few work-streams (Issuance/Acceptance)

Inside a business operation, a particular step (business workflow) works correctly from the business point of view. Upstream/Downstream dependencies stubbed.

End to End Flow Tests

CucumberJMeter/LoadRunner

SMEs + TechBAs + UX + Developers + Arch + Testers (QA + UAT)

When an Internal Milestone is decided, the E2E flow tests are defined & authored. As & when the complete workflow is implemented these tests are enabled.

End to end Trade flow, one layer below the UI

Ensure a specific type of business operation can go thru all the steps successfully.Very important to do detailed performance testing at this stage.

GUI TestsSelenium/Sahi/Watir/White/

SWTBot

TechBAs + UX + Testers (QA)

Usually its takes 3-4 Iterations to complete one whole workflow including the UI. After that the UI tests will be authored and executed.

End to end Trade flow with GUI

Ensure all the basic types of business operations can go through all the steps successfully via a UI.

Page 30: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

“Testing” Touch Points during Project LifecycleProduct Discovery

Release Planning

1st Release Themes

Work-Stream Planning

Iteration Planning

Iteration Iteration Review

Internal Milestone Release

Release

➡Collaborate to create the story map➡Help SMEs to define Acceptance Criteria at each level in story map

➡Define goals & readiness criteria for each Release.

➡Ensure themes are coherent ➡Create theme level epics➡Author End-to-end flow tests

➡Author Work-flow tests➡Collaborate on identifying dependency and documenting them➡Create stream level epics➡Create Integration Test

➡Collaborate with Dev & Biz to write Automated Acceptance Test➡Exploratory Testing➡Buddy testing➡UI automation of previous Iteration tasks➡Performance & Security Tests

➡Sanity Testing in ER cycles➡Confirm user goals are met with operations team➡Participate in Internal Release retrospective

➡Validate Acceptance criteria at story level➡Estimate Tasks

➡Show demo (parts)➡Confirm that the biz requirements are met with stakeholders➡Participate in Iteration retrospectives

➡Sanity Testing in Live environment➡Participate in Release retros

➡The Continuous Integration and Build Pipeline process will execute all tests as part of the regression pack and report various quality parameters to all stakeholders.

➡On going Governance & Test Data management

Page 31: Inverting The Testing Pyramid

Inverting the PyramidHow to…?

Page 32: Inverting The Testing Pyramid

1Acceptance Test/Behavior Driven Development

Page 33: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Acceptance Test Driven Development

Iteration

Automated Acceptance Tests

AutomatedAcceptance Tests

User Story

Acceptance Criteria

Acceptance Criteria

ExploratoryTesting

Automated UI Tests

TESTS

PERFORMENCE

Automated Unit Test

Page 34: Inverting The Testing Pyramid

2Acceptance Criteria Driven Discovery

Page 35: Inverting The Testing Pyramid

Elevator Pitch

Business Goals

Chartering

PragmaticPersonas

User Goals

Day in Life of each Persona

Scenarios & Narratives

Personas

Activity Map

Task MapInteraction

DesignUI Sketch

Story Mapping

PrioritizationGrouping by Themes

Reiterating

Planning

User Stories

AcceptanceCriteria

User Story Authoring

Acceptance Criteria Driven Product Discovery

ParticipantsProduct Manager/Owners

SMEsOperation/Support Reps

Tech BAsUser Experience Designer

App DevelopersArchitects

Testers (QA+UAT)Project Managers

Acceptance

Criteria

Page 36: Inverting The Testing Pyramid

Src:  Jeff  Pa+on,  www.AgileProductDesign.com

Story  mapping  at  SEP

Photo  courtesy  of  So@ware  Engineering  Professionals,  Indianapolis  IN

Page 37: Inverting The Testing Pyramid

Src:  Jeff  Pa+on,  www.AgileProductDesign.com

Organize  &  Visualize  your  Product’s  Release  Roadmap

Page 38: Inverting The Testing Pyramid

3Continuous Integration Pipeline

Page 39: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Typical Continuous Integration ProcessReports

Test

Checkstyle

Test

Page 40: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Continuous Integration Build PipelineLocal

Dev Build

Smoke Build

Functional Build

Cross Stream Build

Theme Build

Product Build

UAT Build

Live Build

Staging Build

Dev Box

Team CI Server

Team CI Server

Dev Env

SIT Env

QA Env

UAT Env

Staging Env

Prod Env

~5 Min

~10 Min

~30 Min

~60 Min

~60 Min

~60 Min

~30 Min

~30 Min

~30 Min

Update

Checkin

Check

out

Publish Artifacts

(jars)

Retr

ieve

Pub

lishe

d A

rtifa

cts

Retriev

e Pub

lished

Artifact

s

Publis

h/Promote

Depend

ent Artif

acts

RetrieveArtifacts

RetrieveArtifacts

Retrieve Published Artifacts

Retrieve Published Artifacts

Checkout

Checkout

Checkout

Checkout

SCM

Each build will update Task statues

Each build will broadcast build stats and other reports to all relevant stakeholders at each stage of the build pipeline

DependencyManagement

Project/Task Management

Tool

VersionControl

Page 41: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Local Dev Build

Smoke Build

Func Build

Cross Stream Build

Theme Build

Prod Build

UAT Build

Staging Build

Live Build

➡DevOps Roles (currently missing) & Test Data strategy is very important to get this working.➡Overall governance model will also be required to make sure build failures are addressed immediately.

Objective

Job

Duration

Stake-holders

Trigger/Frequency

Where

Artifacts

Ensure basic sanity before the developer checks in code.

Ensure the developer has checked in all files, the code compiles, all unit tests work and basic code quality related stats are reported to the devs.

Ensure each story’s business logic is implemented correctly and satisfies the doneness criteria at the story level

Ensure each story integrates with other streams and business logic continues to work as expected.Promote new produced jars to dependent teams.

Ensure each implemented, complete trade workflow works as expected.Interact with as many sub-systems & interfaces as possible.

Ensure each implemented end-to-end feature works as expected including various performance and security related SLAs are met. Also test out the migration scripts

Ensure Operations can execute an end to end workflow and it meets their goals.

Ensure the product as as a whole can work with other systems in the enterprise. Make Go/No-Go decision.

Deploy the product to the live environment.

Retains the environment. Only compiles and tests locally changed code (incremental).

Compiles, Unit test and static/dynamic code analysis on an incremental environment

Clean environment, setup database, team specific biz acceptance tests. Stubs/Mocks out other functional modules or sub-systems.

Integrate promoted code with other modules, runs cross-team workflow & integration tests in an incremental env. Stubs/Mocks other sub-systems. Promote jars to dependent stream.

Clean environment, setup dependent systems, execute theme-level acceptance tests. As few stubs/mocks as possible.

Migrate existing system to the latest version, setup dependent systems, execute product-level acceptance and UI tests. Almost no stubs/mocks.

Migrate existing system to the latest version, setup dependent systems, let the Operations team use the system thoroughly.

Migrate existing system to the latest version, test the system with other systems during the Enterprise Release cycle.

Migrate existing system to the latest version and party!

~ 5 mins. ~ 10 mins. ~ 30 mins ~ 60 mins ~ 60 mins ~ 60 mins ~ 30 mins ~ 30 mins ~ 30 mins

Developer writing the code

Developers of a given team

Team members of a given team + Teach

BA

All functionally affected Teams +

SMEsAll teams + SMEs All teams + SMEs

SCM + SMEs + Operations Team

Enterprise Wide World-wide

Before checking in code. At least every 30 mins.

Every checkin. At least every 30 mins.

On successful Smoke build. At least

every 2 hours

On successful Functional build. At least twice each day

On successful Cross-Stream build. At least once each day

On successful Theme build. At least once

each weekEach Iteration

Each Enterprise Release Cycle

On Successful Staging Build

(Manually triggered for now)

On developer’s workstation

Team CI Server Team CI Server Dev Environment SIT Environment QA Environment UAT EnvironmentStating

EnvironmentProduction Env

Code+Tests+Config

Team produced Jars, static code analysis reports

Team produced Jars/Wars. Static+

Dynamic Code Analysis reports

Integrated jars pushed to

dependent teams

Fully functional app with

workflow level reports

Configured & packaged app (war) with

migration scripts & traceability reports.

Configured & packaged app

(war) with migration scripts

Configured & packaged app (war)

with migration scripts

$$

Page 42: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Example Build Pipeline View

Page 43: Inverting The Testing Pyramid
Page 44: Inverting The Testing Pyramid

Automate 100%

Page 45: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Testing VS. CheckingTesting is explorative, probing and learning oriented.

Checking is confirmative (verification and validation of what we already know). The outcome of a check is simply a pass or fail result; the outcome doesn’t require human interpretation. Hence checking should be the first target for automation.

Michael Bolton explains it really well: “A development strategy that emphasizes checking at the expense of testing is one in which we’ll emphasize confirmation of existing knowledge over discovery of new knowledge. That might be okay. A few checks might constitute sufficient testing for some purpose; no testing and no checking at all might even be sufficient for some purposes. But the more we emphasize checking over testing, and the less testing we do generally, the more we leave ourselves vulnerable to the Black Swan.”

James Bach points out that checking does require some element of testing; to create a check requires an act of test design, and to act upon the result of a check requires test result interpretation and learning. But its important to distinguish between the two because when people refer to Testing they really mean Checking.

Why is this distinction important?

Page 46: Inverting The Testing Pyramid

Copyright © 2013, AgileFAQs. All Rights Reserved.

Thank you

Naresh [email protected]

Questions?