maintainable automated acceptance tests - agile alliance · use executable acceptance criteria as a...

27
http://thoughtworks-studios.com / Maintainable Automated Acceptance Tests Jez Humble Wednesday, January 18, 12

Upload: others

Post on 03-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

http://thoughtworks-studios.com/

Maintainable AutomatedAcceptance Tests

Jez Humble

Wednesday, January 18, 12

Page 2: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

support programming critique the product

technology facingbusiness facing

or

or

Brian Marick

http://www.exampler.com/old-blog/2003/08/21/#agile-testing-project-1Wednesday, January 18, 12

Page 3: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

critique the product

technology facing

business facing

unit tests

functional tests acceptance tests

showcasesexploratory testing

usability testing

performance testssecurity tests

component testssystem testssu

ppor

t pro

gram

min

g

Wednesday, January 18, 12

Page 4: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

UI

Service

Unit

Mike Cohn: Succeeding with Agile

Wednesday, January 18, 12

Page 5: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

End to EndBusiness Facing

Localized Technology Facing

Wednesday, January 18, 12

Page 6: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

“BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

methodology.” - Dan North

behavior-driven development

Wednesday, January 18, 12

Page 7: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

describes system behaviour

uses plain English, with business vocabulary

Given... , When... , Then...

helps ‘business’ and ‘technology’ communicate

automated tests

Wednesday, January 18, 12

Page 8: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Acceptance Criteria"Given ...When ...Then ..."

Test Implementation LayerCode uses domain language; no

reference to UI elements.

Application Driver LayerUnderstands how to interact with the application to perform actions

and return results.

Wednesday, January 18, 12

Page 9: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 10: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 11: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 12: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Acceptance Criteria"Given ...When ...Then ..."

Test Implementation LayerCode uses domain language; no

reference to UI elements.

Application Driver LayerUnderstands how to interact with the application to perform actions

and return results.

Customer Tester

Developer Tester

Developer

Wednesday, January 18, 12

Page 13: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Add a guard to prevent it happening again

Triage to find root cause1. There was an environmental problem2. There is a bug with the test3. An assumption changed4. The test actually caught a bug

Fix the problem

Optimise your process for time to fix tests

Optimise your test suite to detect failures fast

When acceptance tests break

Wednesday, January 18, 12

Page 14: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

#1301As a... I want... So that...

Given... Given...When... When...Then... Then...

#1302As a... I want... So that...

Given... Given...When... When...Then... Then...

#1303As a... I want... So that...

Given... Given...When... When...Then... Then...

#1304As a... I want... So that...

Given... Given...When... When...Then... Then...

#1305As a... I want... So that...

Given... Given...When... When...Then... Then...

#1306As a... I want... So that...

Given... Given...When... When...Then... Then...

#1307As a... I want... So that...

Given... Given...When... When...Then... Then...

#1308As a... I want... So that...

Given... Given...When... When...Then... Then...

#1309As a... I want... So that...

Given... Given...When... When...Then... Then...

#1310As a... I want... So that...

Given... Given...When... When...Then... Then...

#1311As a... I want... So that...

Given... Given...When... When...Then... Then...

#1312As a... I want... So that...

Given... Given...When... When...Then... Then...

#1313As a... I want... So that...

Given... Given...When... When...Then... Then...

#1314As a... I want... So that...

Given... Given...When... When...Then... Then...

#1315As a... I want... So that...

Given... Given...When... When...Then... Then...

#1316As a... I want... So that...

Given... Given...When... When...Then... Then...

#1317As a... I want... So that...

Given... Given...When... When...Then... Then...

#1318As a... I want... So that...

Given... Given...When... When...Then... Then...

Wednesday, January 18, 12

Page 15: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Buy Product

Search product catalogueAdd product to cartCheck outCreate new accountProvide address detailsProvide credit card detailsComplete orderVerify order createdVerify credit card debitedVerify email sent

#1612As a customerI want a gift wrapping optionSo that I don’t have to wrap them and post them myself Buy Product

Search product catalogueAdd product to cartCheck outCreate new accountProvide address detailsProvide credit card detailsSelect gift wrapping optionComplete orderVerify order createdVerify gift wrapping optionVerify credit card debitedVerify email sent

Scenario tests

Wednesday, January 18, 12

Page 16: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Intermittent

Flakey

Flakey

Non-Deterministic

Wednesday, January 18, 12

Page 17: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Flakey

Non-Deterministic

Useless=Wednesday, January 18, 12

Page 18: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Flakey

Non-Deterministic

Useless=worse than

Wednesday, January 18, 12

Page 19: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 20: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 21: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 22: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 23: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Wednesday, January 18, 12

Page 24: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Quarantine

Limit!

Wednesday, January 18, 12

Page 25: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

• Interference caused by dependencies• Asynchrony• Remote services• Time• Resource leaks

Causes

http://martinfowler.com/articles/nonDeterminism.html

Wednesday, January 18, 12

Page 26: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Application reference data

Test-specific data

Test reference data

Don’t use production data dumps (except for performance testing and staging)

Ensure tests are independent from each other

Test data

Wednesday, January 18, 12

Page 27: Maintainable Automated Acceptance Tests - Agile Alliance · Use executable acceptance criteria as a communication mechanism with business Devs can run a single test or a suite on

Don't separate test and dev teams

People with testing capability specify criteria; people with programming capability build test fixture

Use record/playback only for limited cases

Version control tests together with production code

Use mainstream programming environments for your tests

Put time and effort into test data management - don’t use production data

Treat failures seriously

Handle new features iteratively not incrementally

Treat test code as codeUse executable acceptance criteria as a communication mechanism with business

Devs can run a single test or a suite on their dev machine

Build your own abstractions for acceptance criteria

Choosing between UI and subcutaneous tests depends on the architecture of your application

Build tests for parallelizationFix flaky tests

Wednesday, January 18, 12