Top Banner
…building your own AT framework… 21 November, 2003 Sean Hanly
42

…building your own AT framework… 21 November, 2003 Sean Hanly [email protected].

Dec 19, 2015

Download

Documents

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: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

…building your own AT framework…

21 November, 2003

Sean Hanly [email protected]

Page 2: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Acceptance Tests…

- Story of a “Story”

- AT Demonstration

- Pattern- Anti-Patterns- AT Framework Patterns- Process Patterns

- Interactive Session

anything else…

Page 3: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

The Story of a "Story”

Page 4: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

XP Process Overview

Years

MonthsRelease

IterationWeeks

ImplementationDays

Stories

Stories

Story Story Story Story

Tasks

Test Cases

Project

Page 5: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Release Planning

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirement

customer + developers + tester + interaction designer

V(elocity) = 20

Page 6: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Release Plan

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

1

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

2

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

6

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

Bucket

5

5

5

5

5

5

5

5

5

5

5

5

5

5

5

5

Page 7: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Iteration Planning

1

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

this is a short description of a customer’s

requirementthis is a short description

of a customer’s requirement

+AutomatedAcceptance

Tests

customer + developers + tester + interaction designer

5

Page 8: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Implementation Planning

Test

Refactor Code

failingacceptance

test

passing acceptancetest

this is a short description of a customer’s

requirement

acceptancetests

5

Page 9: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

The Story

Page 10: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

A good user story:I Independent N Negotiable

V Valuable / Vertical

E Estimable

S Small

T Testable

Initial Story Presentation(Release Plan)

customer wants the ability to have a rules

engine that allows rules to be evalauted against a clients financial position

Page 11: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

New Story

customer wants the ability toanalyse the amount of casha client is currently holding

-too little- too much- just right

(depends on lifestyle cost and attitude to risk) 25

A good user story:I Independent N Negotiable

V Valuable / Vertical

E Estimable

S Small

T Testable

Page 12: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

2

Release Plan

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

1

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

customer wants the ability toanalyse the amount of casha client is currently holding

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

6

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

Bucket

15

15

25

10

15

25

10

15

10

25

15

15

15

25

5

10

V(elocity) = 65

Page 13: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Release Plan

2

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

1

this is a short description of a customer’s

requirement

customer wants the ability toanalyse the amount of casha client is currently holding

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description. of a customer’s

reuqirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

6

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

this is a short description of a customer’s

requirement

Bucket

15

15

25

10

15

25

10

15

10

25

15

15

15

25

5

10

V(elocity) = 65

Page 14: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Iteration Two

+screen design

+interaction tests

+engine tests

25

customer wants the ability toanalyse the amount of casha client is currently holding

-too little- too much- just right

(depends on lifestyle cost and attitude to risk)

Page 15: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Screen Design

Page 16: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Interaction Tests (example)//Overview“Analyses a clients cash balance to see if they are holding too much cash given their attitude to risk and lifestyle cost…”

//setup client dataUserClicksMainMenu MenuFinancialObjectivesUserInputsText FinancialObjectivesAttitudeToRisk "3 - Low Return - Long " "Term Investment" UserClicksMainMenu MenuCurrentBalanceSheetUserInputsText CurrentBalanceSheetTotalCash 30000 UserClicksMainMenu MenuFinancialObjectivesUserInputsText FinancialObjectivesLifestyleCost 25000

//cash ruleTestValueOfText AnalyseObservation "Given your attitude to risk, you " "should maintain a cash balance no " "greater than €12,500."TestValueOfText AnalyseRecommendation "Consider moving €17,500 from cash " "accounts to investable assets."TestValueOfText AnalyseDestination "Go to Invest Capital Sum and move " "excess cash to cash deposit unless " "holding cash to buy an asset." //hyperlinkUserClicksControl AnalyseDestinationTestValueOfLabel WorkAreaTitle "Invest Capital Sum"

Page 17: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Engine Test (example)

Test Name

Cash AttitudeTo Risk

Lifestyle Cost

Recommended Cash Balance

Disposable Cash

Textual

Analysis

Test 1 30,000 6% 25,000 17,500 17500 Given your attitude to risk, you should maintain a cash balance no greater than €12,500. Consider moving €17,500 from cash accounts to investible assets.

Test 2 10,000 6% 25,000 -2,500 -2500 Given your attitude to risk, you should maintain a cash balance of €12,500. Consider moving €2,500 from Liquid Assets to a Cash Account.

Test 3 15,000 8% 30,000 5,000 5000 Given your attitude to risk, you should maintain a cash balance no greater than €10,000. Consider moving €5,000 from cash accounts to investible assets.

Test 4 10,000 8% 30,000 0 0 Given your attitude to risk, you have an ideal cash balance.

Page 18: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Demonstration

Page 19: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Automated Acceptance Tests

• Unambiguous, Transparent

• Controls Scope Creep

• No Assumptions

• “When do you stop?”

• Surfaces and defines requirements

• Executable Requirements Documentation

• Executable – Asset, Regression Suite

• Test Infecting your Customer

Page 20: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.
Page 21: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

AT Mini-Patterns

Page 22: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Anti-Patterns

Page 23: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

LunaticsRunningTheAsylum

• Problem– The developers create an AT framework that suits the way they think

and the technologies they like or are currently in vogue. As an example we delivered a XML, Cocoon, Java Reflection based framework to our client!!!

• Solution– Eat our own dogfood, i.e. listen to your customer whether they be a

business user, tester, interaction designer. They know what they want to achieve and how they would like it to work, not you!

– Do give them alternatives and possibilites. They may not always be aware of what is possible.

Page 24: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

what happens when the lunatics run the asylum!!

Page 25: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

RecordWhatAndPlaybackWhat

• Problem– Trying to use a GUI based record and playback tool

means that• AT’s cannot be created upfront and • where they are, they the tend to be extremely fragile

due to change i.e. constant re-recording and consequent frustration.

• Solution– Create an AT framework that allows upfront executable

requirements definition e.g. ACT and FIT. – However, record and playback can give you a very cheap

regression suite for legacy code bases.

Page 26: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

MetaLanguageMadness(JAct, Tython )

• Problem– In the effort to create an AT frameowrk the “lunatics”

invent a whole new programming language. This results in un-necessary AT complexity for the customer and the temptation to overload the tests with actual logic, breaking the DRY principle.

• Solution– Remember who the framework will be used by and what

the goal of the framework is.– Create a definition language not a programming

language.

Page 27: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Other anti-patterns

• Test the system not the OS i.e. figure out the boundaries

• AllOrNothing – 80% is ok• Not being subtle enough in setup and

teardown– Using a copy of the complete database

• Testers/Customers will not write code• Allow for some verbosity e.g. FIT• Overly generic e.g. a GUI scripting

language

Page 28: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Patterns

Page 29: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

CreateADomainLanguage(AddACommandLine)

• Problem– When creating an AT framework it is difficult to see how to expose

the system to testing in a manner that allows for definition of requirements and ease of testing. Here intimacy and testability always seem to be the problem. Additionally the framework has to talk to the customer/tester and reflect the domain. Importantly this often means allowing for scripting of actual recognizable usage scenarios.

• Solution– Create a simple verb based, (similar to OS commands), scripting

language for the application– Create high level domain verbs, e.g. CreateCustomer, not low

level calls, e.g. CallSessionBean “jndi::/Customer” createCustomer

– Hook directly into the environment– Verbs should act as client/actor to all parts of the system and be

conversational in nature

Page 30: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

DomainLanguageInsights

• Improves Metaphor

• In the beginning there was the command line – intimacy

• Reusable

• Improves Design

• Becomes a way of interacting with the system

• Leverages existing test code

Page 31: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Example

//setupSetPretendTime “2003,7,23,13,5,6”DeleteAllRecordsInTheDatabase

SetPhoneBalance 353879793001 1000SetPhoneBalance 353879793002 1000SetPhoneBalance 353879793003 1000

//do workSubmitUrl “http://AddNickName…” SubmitUrl “http://AddNickName…”SubmitUrl “http://UpLoadHighScore…”

//check dbTestNumberOfRecordsInDatabase 3TestCustomerRecordEquals “1,8,…”TestCustomerRecordEquals “2,8,…”TestCustomerRecordEquals “3,8,…”

do batch workSetPretendTime “2003,7,24,13,5,6”

RunBatchJob

//check files, database and account balances

CompareFiles expected.out actual.out

TestCustomerRecordEquals “1,10,…”TestCustomerRecordEquals “2,10,…”TestCustomerRecordEquals “3,10,…”

CheckPhoneBalance 353879793001 1000CheckPhoneBalance 353879793002 1000CheckPhoneBalance 353879793003 0985

Page 32: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

BuildInTestability

• Problem– The system in question is difficulut to test because there are no

testing hook’s available.

• Solution– When desiging/building the system add testability. Easiest done

when driving the actual development from acceptance tests. Examples include:

• Recording API’s• Query API’s• Determinism• Fakeability• Undoability• State Management

Page 33: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Legacy: Characterize It

• Problem– Before adding to or refactoring we need a set of acceptance tests

that provide enough feedback to ensure correctness. However, the effort to bring the systen under unit test / acceptance test is prohibitive.

• Solution– Create a coarse grained set of characterization tests that create an

invariant that immdeitely gives feedback as the system as it is changed e.g.

• Log File Comparison• Database Comparison• Record and Playback

Page 34: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Legacy: AddTracerBullets

• Problem– While adding acceptance tests to Legacy Code you find that there

are no testable post conditions.

• Solution– Add safe tracer bullets, i.e. not behaviour changing, to the code

base. As an example add log statements to the major entry and exit points to your system.

Page 35: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Other mini patterns

• TestsAreSource• BringDataUnderControl• IntegrateWithBuild• It’s all right to fake it• Trust your code• Script in the implementation environment• Add determinism• Allow for some verbosity e.g. FIT• Add baseline capability

Page 36: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Process Patterns

Page 37: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Process Patterns

• TestsAreTheRequirements

• TestsAreConversationPieces

• AddSpanners

• EdgeCaseObsession

• HappyPath

Page 38: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Framework Round Up

Page 39: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Frameworks

• Data– FIT– CSV / Excel Driven

• Script– GUI based tools– ACT

• Record Playback– nuff said!– …

Page 40: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

ACT Demo

Page 41: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Bank System(stories to date)

allow for the creation of a new customer account

(open balance should be zero)

allow a customer to deposit money into an

account

allow a customer to withdraw money from an

account

Page 42: …building your own AT framework… 21 November, 2003 Sean Hanly shanly@exoftware.com.

Bank System(new story)

integrate deposit functionality with a fraud

checking system