agile testing best practices

Post on 02-Dec-2014

3.019 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

Have you ever bumped into a wall with your automated tests? Many developers bump into various roadblocks and hurdles when writing test code. Are your test methods starting to fail because the code-under-test uses the current date and time? Are your automated integration tests failing because the database they integrate with keeps changing? Do you have an explosion of test methods, with the ratio of test code to code-under-test way too high? Is your effort to refactor and improve code overwhelmed by the time it takes to rewrite all those failing unit tests? This presentation is about clearing away Agile testing obstacles, avoiding common pitfalls, and staying away from dangerous practices.

TRANSCRIPT

Agile Testing Best Practices

Stephen RitchieDCAST March Meeting19-Mar-2013

Excella Consulting

2

3

1

Agenda

- 2 -

Motivation

Principles

Obstacles

Excella Consulting

Motivation

Why Test Software?

Excella Consulting

Chrysler New Yorker

Excella Consulting

Motivation

Why Write Automated

Tests?

Excella Consulting

Achieve Desired Results

• Software costs too much• Users demand quality• Testing takes too long• New features take too long

Excella Consulting

Microscope: Visibility and Insight

Excella Consulting

Smoke Detector: Problem Detection

Excella Consulting

Weather Satellite: Advanced Warning

Software Works

Make Sure

As Intended

Automated Tests

Excella Consulting

2

3

Agenda

- 12 -

Motivation

Principles

Obstacles

1

Excella Consulting

Agile Test Pyramid: Vision

Engineers

Testers

Aut

omat

ed

http://bit.ly/10QubsyGoogle “Agile Test Pyramid”

Excella Consulting

Agile Test Pyramid: Reality

http://bit.ly/10QpUFGIce-Cream Cone Anti-Pattern

Excella Consulting

Agile Test Quadrants

Excella Consulting

Principles

1. Unit Test

Developer Tests“Intention Checking”

Excella Consulting

Principles

2. Automate• Always running• Can't be bargained with• Can't be reasoned with• Tests don't feel pity or

remorse or fear• Absolutely will not stop,

ever, until you deliver a quality software product.

Excella Consulting

Principles

2. Automate• CI Server

• Per Commit• Overnight Functional• Smoke Testing• Stability Testing• Performance/Load

• Automate Deployments• Project “Dashboard”

Excella Consulting

Principles

3. Zero Configuration*

I can run your tests,You can run mine.

* One-time configuration is okay

Excella Consulting

Principles

4. Fast

All tests run time efficiently

Excella Consulting

Principles

5. Clear Results

Pass/Fail

Focused Test

Isolates Issue

Excella Consulting

Principles

6. Easy to Maintain

Conventional

Brief

Excella Consulting

Principles

7. TimelyTest-Driven Development (TDD)

Test As-It’s-Built

Test As-It’s-Fixed

Excella Consulting

3

Agenda

- 24 -

Motivation

Principles

Obstacles

1

2

Excella Consulting

Requirements, Requirements, Requirements

•Too Abstract•Changing•Over Specification

Obstacle 1

Excella Consulting

Specification by Example

Examples & Feature Files

Excella Consulting

One Primary Assert To Rule Them All

One Primary Assert

Excella Consulting

Time Crunch

Obstacle 2

Time Crunch

Excella Consulting

Four Ways to Fake Time

• Virtual Machine• Isolate The System

• Inspect The Clock

• Dummy IClock

Fake Time

Real System Clock

Dummy Clock

IClock Interface

System Under Test

Excella Consulting

Database Killed The Integration Test

Obstacle 3

DatabaseIntegration

Excella Consulting

Fixture Setup and Data Arrangement

Excella Consulting

Fixture Setup and Data Arrangement

• Schema Migration– RoundhousE– Flyway Db– Liquibase

• Data Arrangement– DbUnit &

NDbUnit

Excella Consulting

Now We Have Too Much Test Code

Obstacle 4

Explosion ofTest Code

Excella Consulting

Monitor Test Code Growth Rate

Control Growth• Monitor The Ratio

• Data-Drive Tests

• Boundary Analysis

Excella Consulting

Bad Coupling

Obstacle 5Unhelpful Reuse

Unhelpful Repetition

Unhelpful Coupling

Excella Consulting

In Test Code, Do Repeat Yourself ... Do Repeat Yourself

Test Code Is Different• Avoid Inheritance Reuse• Use “Context” Helpers• Repetition Is Better Than Coupling

Excella Consulting

Agenda

- 41 -

Motivation

Principles

Obstacles

1

2

3

Excella Consulting

Of Course It’s Safe … After You

Excella Consulting

Shameless Self Promotion Time!

• “Best Practices” Initiative• Tips and Tricks• Generate Ideas

• Quantifying Value• Biases & Aversions• Tools & Technologies

• Avoid Making the Same Mistake Once.

Excella Consulting

Code and Slides

• Code: https://github.com/ruthlesshelp

• Slides: http://www.slideshare.net/ruthlesshelp

Excella Consulting

Contact Me

• Email: stephen.ritchie@excella.com• Twitter: @ruthlesshelp• Blog: http://ruthlesslyhelpful.net• LinkedIn: http://www.linkedin.com/in/

sritchie

top related