From Use Cases to Test Cases - aspe-sdlc. · PDF fileFrom Use Cases to Test Cases. ......

80
1 From Use Cases to Test Cases Marc J. Balcer Chief Architect Model Compilers LLC

Transcript of From Use Cases to Test Cases - aspe-sdlc. · PDF fileFrom Use Cases to Test Cases. ......

1

From Use Cases to Test Cases

Marc J. BalcerChief ArchitectModel Compilers LLC

2

Marc J. BalcerFounder & Chief ArchitectModel Compilers

email: [email protected]

Author of Executable UML and Applied SOA

ASPE Lead Instructor for Modeling Techniques for Business Analysis Object-Oriented Design with UMLBuilding the Logical Data ModelRanorex Test Automation Workshop

Instructor

TAM

ETe

s tA

utho

ring

Mad

eEa

sy

3

Outline

• Structure to Manage Complexity:System – Process – Activity – Action

• Use key elements from use cases• Flows• Pre- and post-conditions

• Create tests bottom-up• Test the actions• Chain actions and activities

• Manage Coverage

4

Who uses use cases?

5

Who builds test cases?

6

What’s a test case?

7

“Fully Dressed” use caseName

Employee Reports ExpensesScope

Expense ReportingLevel

User GoalPrimary Actor

EmployeeStakeholders and Interests

Employee – wants to be reimbursed for expenses incurred during travel or other business activitiesConsulting Firm – wants to be able to track reimbursable business expenses, to reimburse employees, and to bill customers for billable expensesCustomer – needs to be billed for those expenses and wants justification for those expensesFinance Department – needs to authorize reimbursements and to bill customers according to customer contracts

PreconditionsAn Employee has expenses to report.

Minimal GuaranteesAn expense report has been filed.

Success GuaranteesThe employee has been reimbursed for expenses.

Main Success Scenario1. The employee opens the expense tracking system in a web browser by

entering the URL of the expense tracking system or by clicking the Expenseslink on the company intranet home page.

2. The employee selects “New Expense Report”3. The employee enters the trip date and purpose.4. The employee begins entering expenses by clicking “New Expense,” selecting

the type of expense, entering the date, amount, and description of theexpense, and pressing “Add.”

5. The employee may attach a receipt by uploading a scanned image file whenentering the expense item.

6. When the employee has finished entering expenses, he presses “Submit forapproval.”

7. The employee logs out.8. The expense report is sent to the manager.9. The manager receives an email containing a summary of the expense report

and a link to the expense report.10. The manager approves the expense report.11. The manager clicks on the link in the email.12. If the manager is not already logged in, he is prompted to log in by entering his

user ID and password.13. The manager reviews the expense report. He checks to make sure that all

expenses are permitted and that all expenses over $25 have attached receipts.14. The manager clicks “Approve.”15. The expense report is sent to the Finance department.16. Finance does not receive emails, rather the controller (or her designates)17. A Controller in the Finance department authorizes reimbursement.18. The employee receives reimbursement for expenses.

How many test cases are needed to test this?

8

Key ComponentsName

Employee Reports ExpensesScope

Expense ReportingLevel

User GoalPrimary Actor

EmployeeStakeholders and Interests

Employee – wants to be reimbursed for expenses incurred during travel or other business activitiesConsulting Firm – wants to be able to track reimbursable business expenses, to reimburse employees, and to bill customers for billable expensesCustomer – needs to be billed for those expenses and wants justification for those expensesFinance Department – needs to authorize reimbursements and to bill customers according to customer contracts

PreconditionsAn Employee has expenses to report.

Minimal GuaranteesAn expense report has been filed.

Success GuaranteesThe employee has been reimbursed for expenses.

Main Success Scenario1. The employee opens the expense tracking system in a web browser by

entering the URL of the expense tracking system or by clicking the Expenseslink on the company intranet home page.

2. The employee selects “New Expense Report”3. The employee enters the trip date and purpose.4. The employee begins entering expenses by clicking “New Expense,” selecting

the type of expense, entering the date, amount, and description of theexpense, and pressing “Add.”

5. The employee may attach a receipt by uploading a scanned image file whenentering the expense item.

6. When the employee has finished entering expenses, he presses “Submit forapproval.”

7. The employee logs out.8. The expense report is sent to the manager.9. The manager receives an email containing a summary of the expense report

and a link to the expense report.10. The manager approves the expense report.11. The manager clicks on the link in the email.12. If the manager is not already logged in, he is prompted to log in by entering his

user ID and password.13. The manager reviews the expense report. He checks to make sure that all

expenses are permitted and that all expenses over $25 have attached receipts.14. The manager clicks “Approve.”15. The expense report is sent to the Finance department.16. Finance does not receive emails, rather the controller (or her designates)17. A Controller in the Finance department authorizes reimbursement.18. The employee receives reimbursement for expenses.

9

Structure toManage Complexity

10

but they all seem to have

27 steps…

I don’t think myuse cases are too

detailed…

11

Use Case “Levels”

It’s not level of detail, it’s subject matter!• Business Structure

• Enterprise : consulting firm• Line of Business : training• Business Function: expense reporting

• System Structure• User Interface• Messaging Behavior• Hardware Control

12

There can be several ways to report expenses

Navigate through web pages and use

popups to add expenses to the

report.

Navigate through pages

and click buttons to add expenses

to the report.

Web GUI Smartphone App

Expense Reporting

Business Process vs. User Interface

Submit the entire expense report as an XML message.

Web Service

13

Technique:Separate business process

from user interface

14

Use Case Flow1. The employee opens the expense tracking system in a web browser by entering the URL of the expense

tracking system or by clicking the Expenses link on the company intranet home page.2. The employee selects “New Expense Report”3. The employee enters the trip date and purpose.4. The employee begins entering expenses by clicking “New Expense,” selecting the type of expense, entering the

date, amount, and description of the expense, and pressing “Add.”5. The employee may attach a receipt by uploading a scanned image file when entering the expense item.6. When the employee has finished entering expenses, he presses “Submit for approval.”7. The employee logs out.8. The expense report is sent to the manager.9. The manager receives an email containing a summary of the expense report and a link to the expense report.10. The manager approves the expense report.11. The manager clicks on the link in the email.12. If the manager is not already logged in, he is prompted to log in by entering his user ID and password.13. The manager reviews the expense report. He checks to make sure that all expenses are permitted and that all

expenses over $25 have attached receipts.14. The manager clicks “Approve.”15. The expense report is sent to the Finance department.16. Finance does not receive emails, rather the controller (or her designates)17. A Controller in the Finance department authorizes reimbursement.18. The employee receives reimbursement for expenses.

15

Use Case Flow (outlined levels)1. The employee records his expenses by entering them into the expense tracking system.

a. The employee opens the expense tracking system in a web browser by entering the URL of the expensetracking system or by clicking the Expenses link on the company intranet home page.

b. The employee selects “New Expense Report”c. The employee enters the trip date and purpose.d. The employee begins entering expenses by clicking “New Expense,” selecting the type of expense,

entering the date, amount, and description of the expense, and pressing “Add.”e. The employee may attach a receipt by uploading a scanned image file when entering the expense item.f. When the employee has finished entering expenses, he presses “Submit for approval.”g. The employee logs out.

2. The expense report is sent to the manager.a. The manager receives an email containing a summary of the expense report and a link to the expense

report.3. The manager approves the expense report.

a. The manager clicks on the link in the email.b. If the manager is not already logged in, he is prompted to log in by entering his user ID and password.c. The manager reviews the expense report. He checks to make sure that all expenses are permitted and

that all expenses over $25 have attached receipts.d. The manager clicks “Approve.”

4. The expense report is sent to the Finance department.a. Finance does not receive emails, rather the controller (or her designates)

5. A Controller in the Finance department authorizes reimbursement.6. The employee receives reimbursement for expenses.

16

Business Flow

1. The employee records his expenses by entering them into the expense tracking system.

2. The expense report is sent to the manager.3. The manager approves the expense report.4. The expense report is sent to the Finance

department.5. A Controller in the Finance department authorizes

reimbursement.6. The employee receives reimbursement for

expenses.

17

UI Flow – Employee Records Expenses 1. The employee opens the expense tracking system in a web browser by

entering the URL of the expense tracking system or by clicking the Expenses link on the company intranet home page.

2. The employee selects “New Expense Report”3. The employee enters the trip date and purpose.4. The employee begins entering expenses by clicking “New Expense,”

selecting the type of expense, entering the date, amount, and description of the expense, and pressing “Add.”

5. The employee may attach a receipt by uploading a scanned image file when entering the expense item.

6. When the employee has finished entering expenses, he presses “Submit for approval.”

7. The employee logs out.

18

UI Flow – Employee Records Expenses 1. The employee opens the expense tracking system in a web browser by

entering the URL of the expense tracking system or by clicking the Expenses link on the company intranet home page.

2. If not already logged in, the employee logs in with his user ID and password.

3. The employee selects “New Expense Report”4. The employee enters the trip date and purpose.5. The employee begins entering expenses by clicking “New Expense,”

selecting the type of expense, entering the date, amount, and description of the expense, and pressing “Add.”

6. The employee may attach a receipt by uploading a scanned image file when entering the expense item.

7. When the employee has finished entering expenses, he presses “Submit for approval.”

8. The employee logs out.

20

A picture’s worth a thousand words.

A good sketch is better than a long

speech.

Un bon croquisvaut mieux qu’un

long discours.

21

Em

plo

yee

Man

ager

Co

ntr

oll

er

Employ ee has expenses to report

SubmitExpenseReport

ApproveExpenseReport

PayReimbursement

Reimbursement Pay ment

Submitted Expense Report

Approved Expense Report

Business Process

Notification

(Sequence) Flow

22

Em

plo

yee

Man

ager

Co

ntr

oll

er

Employ ee has expenses to report

SubmitExpenseReport

ApproveExpenseReport

PayReimbursement

Reimbursement Pay ment

Submitted Expense Report

Approved Expense Report

Business Process

23

Em

plo

yee

Man

ager

Co

ntr

oll

er

Employ ee has expenses to report

SubmitExpenseReport

ApproveExpenseReport

PayReimbursement

Reimbursement Pay ment

Submitted Expense Report

Approved Expense Report

Activity: UI Flow

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

24

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Activity: UI Flow

Navigation

25

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Activity: UI Flow

26

Display

Abstract representation of• a window• a page• a popup• a report• a paper form…any sort of thing that collects or displays information in a business process step.

Company Homepage

27

Company Homepage

Display Contents

select

Optionally indicate the contentsof each display

28

New Expense Report

Display Action Steps

Or indicate what the user is expected to do here

Trip Date ________Purpose _______

Add

29

Hierarchy of Concepts

System

Process

Activity

Action

*

*

*E

mp

loye

eM

anag

erC

on

tro

ller

Employ ee has expenses to report

SubmitExpenseReport

ApproveExpenseReport

PayReimbursement

Reimbursement Pay ment

Submitted Expense Report

Approved Expense Report

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Ana

lyze

dow

n

Build up

30

Build Individual Action Tests

31

Login

User IDPassword

Action (Page) Test

32

Characteristic Values

emptybad

syntax

too long

good syntax

33

Input: User ID

emptybad

syntax

too long

good syntax

Login Screen

Input User ID FieldEmptyToo longDisallowed charactersGood syntax

34

Common Input Values

• Errors• Missing (empty, null, nothing, unchecked, …)• Too short• Too long• Wrong characters (bad syntax)• Out of range

• Acceptable Values• Good syntax• Special characters

(e.g. quotes, < > characters)• Non-ASCII and non-Latin characters

35

Input: Password

Login Screen

Input User ID FieldEmptyToo longDisallowed charactersGood syntax

Input Password FieldEmptyToo longGood syntax

Login Screen

Input User ID FieldEmptyToo longDisallowed charactersGood syntax

Input Password FieldEmptyToo longGood syntax

4 x 3 = 12 total test cases

Test Case 1:User ID Field: EmptyPassword Field: Empty

Test Case 2:User ID Field: EmptyPassword Field: Too long

Test Case 3:User ID Field: EmptyPassword Field:

Disallowed characters

Test Case 4:User ID Field: EmptyPassword Field: Good syntax

Test Case 5:User ID Field: Too longPassword Field: Empty

pretty much

the same

37

10 inputs3 choices each

310 = 59,049 combinations

38

Mapping Inputs to Results

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmptyToo longDisallowed charactersGood syntax

Input Password FieldEmptyToo longGood syntax

39

Mapping Inputs to Results

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo longGood syntax x

40

Expected Results

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo longGood syntax x

41

Expected Results

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo longGood syntax x

42

“Don’t Care”

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo longGood syntax x

“don’t care” what choice is made—the result is always the same

43

Multiple Input Conditions

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo longGood syntax x

44

Multiple Choices

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo longGood syntax x

One test case for each of these

choices

45

Multiple Result Conditions

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo long xGood syntax x

Two ways to the same

result

46

Inputs and Results

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo long xGood syntax x

47

Generated Test Cases

User ID Field Password Field Results...

1 Empty User ID Missing Error

2 Empty Password Missing Error

3 Too long Bad Login Error

4 Disallowed characters Bad Login Error

5 Too long Bad Login Error

6 Good syntax Good syntax Can Login

48

“Don’t care” inputs

User ID Field Password Field Results...

1 Empty User ID Missing Error

2 Empty Password Missing Error

3 Too long Bad Login Error

4 Disallowed characters Bad Login Error

5 Too long Bad Login Error

6 Good syntax Good syntax Can Login

49

“Don’t care” inputs

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo long xGood syntax x

“don’t care” what choice is made—the result is always the same

54

Explicit Choices

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Can

Logi

n

Input User ID FieldEmpty xToo long x xDisallowed characters x xGood syntax x x

Input Password FieldEmpty xToo long xGood syntax x

Explicit choices:now I “do care”

User ID Field Password Field Results...

1 Empty User ID Missing Error

2 Too long Empty Password Missing Error

3 Disallowed characters Empty

4 Good syntax Empty

5 Too long Bad Login Error

6 Disallowed characters Bad Login Error

7 Too long Bad Login Error

8 Good syntax Good syntax Can Login

56

Inputs are not Enough

User ID Field Password Field Results...

1 Empty User ID Missing Error

2 Empty Password Missing Error

3 Too long Bad Login Error

4 Disallowed characters Bad Login Error

5 Too long Bad Login Error

6 Good syntax Good syntax Can Login

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax

Input Password FieldEmpty xToo long xGood syntax

Condition UserNo user with the user IDUser ID names a good user

Condition PasswordNot correct for the userCorrect for the user

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax

Input Password FieldEmpty xToo long xGood syntax

Condition UserNo user with the user IDUser ID names a good user

Condition PasswordNot correct for the userCorrect for the user

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x

Input Password FieldEmpty xToo long xGood syntax x

Condition UserNo user with the user ID xUser ID names a good user

Condition PasswordNot correct for the userCorrect for the user

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x x

Input Password FieldEmpty xToo long xGood syntax x x

Condition UserNo user with the user ID xUser ID names a good user x

Condition PasswordNot correct for the user xCorrect for the user

Login Screen

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Succ

essf

ul L

ogin

Input User ID FieldEmpty xToo long xDisallowed characters xGood syntax x x x

Input Password FieldEmpty xToo long xGood syntax x x x

Condition UserNo user with the user ID xUser ID names a good user x x

Condition PasswordNot correct for the user xCorrect for the user x

User ID Field Password Field User Password Results...

1 Empty User ID Missing Error

2 Empty Password Missing Error

3 Too long Bad Login Error

4 Disallowed characters Bad Login Error

5 Too long Bad Login Error

6 Good syntax Good syntax No user with the user ID Bad Login Error

7 Good syntax Good syntax User ID names a good user

Not correct for the user Bad Login Error

8 Good syntax Good syntax User ID names a good user

Correct for the user Successful Login

emptybad

syntax

too long

good syntax

emptybad

syntax

too long

good syntax

special attention:• valid non-alphanumeric characters• extended Latin characters• non-Latin characters

special attention:• greater-than and less-than signs• invalid non-alphanumeric characters

Function Name

Use

r ID

Miss

ing

Erro

r

Pass

wor

d M

issin

g Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Bad

Logi

n Er

ror

Succ

essf

ul L

ogin

Input User ID FieldEmpty xToo long xDisallowed characters xGreater than and less than xGood regular alphanumeric x x xValid non-alphanumeric x x xExtended Latin characters x x xNon-Latin characters x x x

Input Password FieldEmpty xToo long xGood syntax x x x

66

TAME the rest of the actions (pages)

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

67

Hierarchy of Concepts

System

Process

Activity

Action

*

*

*E

mp

loye

eM

anag

erC

on

tro

ller

Employ ee has expenses to report

SubmitExpenseReport

ApproveExpenseReport

PayReimbursement

Reimbursement Pay ment

Submitted Expense Report

Approved Expense Report

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Ana

lyze

dow

n

Build up

68

Test pathsthrough the activity

69

Main Success Scenario (“happy path”)

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

70

One Alternate “happy path”

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

71

An Alternate “not success path”

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

72

Chaining Actions

Login Company Homepage

Login[successful]

The result of a successful login…

…is a precondition to viewing the company homepage

73

Chaining Actions

Login Company Homepage

Login[successful]

There are two distinct possibilities from the Login page

Login[unsuccessful]

(we’ll ignore the loop for now)

74

Graph Coverage Methods

• Node

• Edge

• Path

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

75

Graph Coverage Methods

• Node

• Edge

• Path

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Create enough paths to visit each box (action) at least once.

76

Graph Coverage Methods

• Node

• Edge

• Path

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Create enough paths to traverse each transition (arrow) at least once.

77

Graph Coverage Methods

• Node

• Edge

• Path

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

Find every distinct path through the graph.

78

Path Enumeration

Employeehas expensesto report

Company Intranet

Homepage

Expense Reporting Main

Login New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

User IDPassword

Homepage URL

Login[successful]

ExpensesLink

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Logout

Login[unsuccessful]

Cancel

79

Loops

• Test zero times

• Test one time

• Test “many” times(e.g. 3)

nse g Main

New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Cancel

80

Loops

• Test zero times

• Test one time

• Test “many” times(e.g. 3)

nse g Main

New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Cancel

81

Loops

• Test zero times

• Test one time

• Test “many” times(e.g. 3)

nse g Main

New Expense Report

New Expense Item

Add ReceiptExpense Reporthas beensubmitted to theManagerReturns to

main page

Trip DatePurpose

Scanned Image

TypeDateAmountDescription

NewExpense

Report New Expense

AddReceipt

Add;Cancel

Add;Cancel

Submit forApproval

Cancel

82

Coverage Levels for Different Purposes

• Quick Sanity Tests• Main Success Scenarios• Good inputs only• One iteration of loops

• Periodic (“Daily”) Build Tests• Node Coverage• “Don’t Care” other options on error inputs• Zero and one iteration of loops

• Complete Exhaustive Tests• Path Coverage• All combinations of inputs• Zero, one, and many iterations of loops

83

Complete Exhaustive Tests

84

Use Cases to Test Cases

• Structure to Manage Complexity:System – Process – Activity – Action

• Use key elements from use cases• Flows• Pre- and post-conditions

• Create tests bottom-up• Test the actions• Chain actions and activities

• Manage Coverage

85

Marc J. BalcerFounder & Chief Architect

Model Compilers

email: [email protected]