Download as pdf or txt
Download as pdf or txt
You are on page 1of 100

Section 4

Cause-Effect Graphing

Copyright 2006 Bender RBT Inc. 1

Copyright 2006 Bender RBT Inc. 1


Objectives

In this section, you will gain an


understanding of:
• the logical operators of a cause-effect graph.
• how to draw the basic constructs of a cause-
effect graph.
• how to create a cause-effect graph from a
requirement.

Copyright 2006 Bender RBT Inc. 2

Copyright 2006 Bender RBT Inc. 2


Cause-Effect Graphing
If A or B, then C.
If D or E, then F.
A
If C and F, then G. C
Or
B
• Resolve Aliases
And G
• Clarify Precedence Rules D
• Clarifies Implicit
Or
Information F
• Begin Integration Test E

Copyright 2006 Bender RBT Inc. 3

Copyright 2006 Bender RBT Inc. 3


Cause-Effect Graphing

• Superficially intimidating.

• You only need to know the definition of:


AND, OR, NOT.

• Forces the issue on the level of detail in


specifications.

• Allows us to apply hardware logic


testing algorithms to software testing.

Copyright 2006 Bender RBT Inc. 4

Copyright 2006 Bender RBT Inc. 4


Cause-Effect Graphing

• Logical Operators
• Exercise
• Basic Logic Constructs
• Common Cases
• Big Exercise
• Yet Another Exercise - Graphing from Bad
Specs
• Special Cases
• Graphing Summary

Copyright 2006 Bender RBT Inc. 5

Copyright 2006 Bender RBT Inc. 5


Logical Operators

1. Simple
2. Inclusive Or (…)
3. Exclusive Or (ˆ)
4. And („ )
5. Nor (‡)
6. Nxor ( ‰)
7. Nand (†)
8. Negation (ƒ)

Copyright 2006 Bender RBT Inc. 6

Copyright 2006 Bender RBT Inc. 6


Logical Operators

1. Simple
– If A then B.
– If you go through a red light then you
get a ticket.
Nodes

A B

Vector

Copyright 2006 Bender RBT Inc. 7

Copyright 2006 Bender RBT Inc. 7


Logical Operators

Nodes
• Variable at a State
Light is Red
Transaction Amount > Zero

• Function or an Action
If the Amount > Zero then
CALCULATE_THE_INTEREST
The User hits the Enter Button

Copyright 2006 Bender RBT Inc. 8

Copyright 2006 Bender RBT Inc. 8


Logical Operators

Defining Nodes – Variable States

Input Domain:
Set of all possible values for the variable(s) in
question.
Input Domain parsed (divided) into subsets by
specifying an attribute and an operator that is
applied to that attribute:
• List
• Range
• Category

Copyright 2006 Bender RBT Inc. 9

Copyright 2006 Bender RBT Inc. 9


Logical Operators
Defining Nodes

Set Is All Employees


Subset by list:
Charles Smith
Sally Jones
Sam Chen
Subset by range:
Employees with employee numbers 0001 through 0250.
Subset by category:
All Female employees.

Copyright 2006 Bender RBT Inc. 10

Copyright 2006 Bender RBT Inc. 10


Logical Operators
• Defining Nodes

• Other possible states include “starts with”,


“contains”

– Employees with a Last Name that starts with “Sm”


– Employees with a Job Title that contains “Engineer”

Copyright 2006 Bender RBT Inc. 11

Copyright 2006 Bender RBT Inc. 11


Logical Operators

2. Inclusive Or ( … )
– If A or B then C.
– If you go through a red light or pass a stopped
school bus then you get a ticket.

A B C
A
… C
B Operator

Copyright 2006 Bender RBT Inc. 12

Copyright 2006 Bender RBT Inc. 12


Logical Operators

3. Exclusive Or ( ˆ )
– If one and only one of A or B then C.
– If the customer has either product A or product
B, but not both, give them product C.
A B C
A
ˆ C
B

Copyright 2006 Bender RBT Inc. 13

Copyright 2006 Bender RBT Inc. 13


Logical Operators

4. And ( „ )
– If A and B then C.
– If you go through a red light and the
officer stops you, then you get a ticket.

A A B C

C
B

Copyright 2006 Bender RBT Inc. 14

Copyright 2006 Bender RBT Inc. 14


Logical Operators
5. Nor ( ‡ )
– If not [A or B] then C.
– If John is neither absent nor late to
school all semester, then he will get a
perfect attendance award.

A
A B C
‡ C
B

Copyright 2006 Bender RBT Inc. 15

Copyright 2006 Bender RBT Inc. 15


Logical Operators
6. Nxor (‰)

- If not [A xor B] then C


- If neither option A nor B is selected or if both
option A and B are selected, then display the
error message.

Copyright 2006 Bender RBT Inc. 16

Copyright 2006 Bender RBT Inc. 16


Logical Operators

7. Nand ( † )
– If not [A and B] then C.
– If it’s not [the Eagles and the Raiders playing]
then I’ll go to the game.

A
‡ A B C
C
B

Copyright 2006 Bender RBT Inc. 17

Copyright 2006 Bender RBT Inc. 17


Logical Operators

8. Negation ( ƒ )
– If not A then B. A B

A
– If A or [not B] … C
B
then C.

Copyright 2006 Bender RBT Inc. 18

Copyright 2006 Bender RBT Inc. 18


Logical Operators
Do not hide negation in the node definition.
 Incorrect
A A = Rains
… C B = Snows
B C = Do NOT go on a hike.

 Correct
A A = Rains
‡ C B = Snows
B
C = Go on a hike.
Copyright 2006 Bender RBT Inc. 19

Copyright 2006 Bender RBT Inc. 19


Logical Operators
~ ~
A ‡B = A „B
If neither A nor B = If not A and not B.
A A ƒ

‡ C = C
B B ƒ
A B C
 If Bob flunks neither the midterm nor
the final then he will pass the course.
 If Bob does not flunk the midterm and
does not flunk the final then he will
pass the course.
Copyright 2006 Bender RBT Inc. 20

Copyright 2006 Bender RBT Inc. 20


Logical Operators
~ ~
Note: A‡B = A „B
If neither A nor B = If not A and not B.
~ ~
A †B = A …B
If not [A and B] = If not A or not B.
~ ~
A †B ≠ A „B
If not [A and B] ≠ If not A and not B.
~ ~
A‡ B ≠ A … B
If not [A or B] ≠ If not A or not B.

Copyright 2006 Bender RBT Inc. 21

Copyright 2006 Bender RBT Inc. 21


Exercise 4-1: Complete the Cause-Effect
Graphs and List the Nodes. Watch for
Ambiguities.
1. If the light is red then stop.
A.
B.

2. If the action code is ‘2’ and the amount is greater


than $50.00 make an entry on the report.
A. A
B. C
C. B

3. The report is printed at year-end or on request.


A. A
B. C
C. B

Copyright 2006 Bender RBT Inc. 22

Copyright 2006 Bender RBT Inc. 22


Exercise 4-1

4. If it does not rain or snow the tennis match


will be played.
A. A
B. C
C. B
A
A.
C
B.
B
C.

5. If it does not rain or snow we will go skiing.


A. A
B. C
C. B

Copyright 2006 Bender RBT Inc. 23

Copyright 2006 Bender RBT Inc. 23


Exercise 4-1
6. The report is printed unless the action code is
‘T’ and it is also year-end.
A. A
B. C
C. B

A. A
B. C
C. B

7. If only Sally or Sarah go to the party,


then Harry will go too. A
A. C
B. B
C.
Copyright 2006 Bender RBT Inc. 24

Copyright 2006 Bender RBT Inc. 24


Exercise 4-1: Answers
1. If the light is red then stop.
A. Light is red
A B
B. Stop

2. If the action code is ‘2’ and the amount is greater


than $50.00 make an entry on the report.
A
A. Action code is ‘2’
„ C
B. Amount > $50.00
B
C. Entry on report

3. The report is printed at year-end or on request.


A
A. Year-end
… C
B. On-request
B
C. Report
Copyright 2006 Bender RBT Inc. 25

Copyright 2006 Bender RBT Inc. 25


Exercise 4-1: Answers

4. If it does not [rain or snow] the tennis match


will be played.
A. Rain
B. Snow A
‡ C
C. Play tennis
B
A. Rain A ƒ
B. Snow „ C
C. Play tennis B ƒ
5. If it does[ not [rain] or snow] we will go skiing.
A. Rain A ~ A
B. Snow … C ‡ C
C. Skiing B B

Copyright 2006 Bender RBT Inc. 26

Copyright 2006 Bender RBT Inc. 26


Exercise 4-1: Answers
6. The report is printed unless the action code is
‘T’ and it is also year-end.
A. Action code is ‘T’ A ƒ A
B. Year-end … C † C
C. Print report B ƒ B

A. Action code is ‘T’ A


B. Year-end „ C
C. No report B

7. If only Sally or Sarah go to the party,


then Harry will go too. A
A. Sally goes to the party. ˆ C
B. Sarah goes to the party. B
C. Harry goes to the party.
Copyright 2006 Bender RBT Inc. 27

Copyright 2006 Bender RBT Inc. 27


Basic Logic Constructs

1. Simple.
2. Compound Ifs.
3. Peer Level Ifs - (Order of the statements is not
important).
4. Nested Ifs - (Order of the statements is
important).
5. Case Statement.

Copyright 2006 Bender RBT Inc. 28

Copyright 2006 Bender RBT Inc. 28


Basic Logic Constructs
1. Simple
– If A, then B. A B

B
– If A, then B; else C. A
ƒ C

(Else, Otherwise, If Not...)

Copyright 2006 Bender RBT Inc. 29

Copyright 2006 Bender RBT Inc. 29


Basic Logic Constructs

1. Simple (continued) B

– If A, then B, C, and D. A C
D

B
C
– If A, then B, C, and D; else A
D
E. ƒ
E

Copyright 2006 Bender RBT Inc. 30

Copyright 2006 Bender RBT Inc. 30


Basic Logic Constructs
1. Simple (continued)
• Avoid Compound Nodes
“If error, then display message, reset cursor, and
highlight the field.”
Error Notify User
Incorrect -

Display M essage
Correct -
Error Reset Cursor
Highlight Field

Copyright 2006 Bender RBT Inc. 31

Copyright 2006 Bender RBT Inc. 31


Basic Logic Constructs

2. Compound If

– If A or B or C, then D.

A A
B … D B … D
C C
Caution: Stop the
vector at the arc

Copyright 2006 Bender RBT Inc. 32

Copyright 2006 Bender RBT Inc. 32


Basic Logic Constructs

2. Compound If (continued)

Else Case Style (short form)


– If A or B or C, then D; else E.

A E
ƒ

B … D
C

Copyright 2006 Bender RBT Inc. 33

Copyright 2006 Bender RBT Inc. 33


Basic Logic Constructs
2. Compound If (continued)

Else Case Style (explicit)


– If A or B or C, then D; else E.

Copyright 2006 Bender RBT Inc. 34

Copyright 2006 Bender RBT Inc. 34


Basic Logic Constructs

3. Peer Level Ifs


(order of the statements is not
important).
A
C
– If A or B, then C. …
– If D or E, then F. B
– If C and F, then G. „ G


F
E

Copyright 2006 Bender RBT Inc. 35

Copyright 2006 Bender RBT Inc. 35


Basic Logic Constructs
Primary Causes, Primary Effects,
Intermediate Nodes

A
C Intermediate
… Nodes
B
Primary „ G
Causes
D
Primary
… Effects
F
E

Copyright 2006 Bender RBT Inc. 36

Copyright 2006 Bender RBT Inc. 36


Basic Logic Constructs
Intermediate Nodes - Real
– If the transaction code is 1 and it is year-end then close the
account.
– If the transaction code is 2 and it is month-end then re-open the
account.
– If an account is closed or re-opened then create an account
status change notice. T/ C 1
… C/ A

Y-E

Change
Notice
T/ C 2

R-O/ A
M-E
Copyright 2006 Bender RBT Inc. 37

Copyright 2006 Bender RBT Inc. 37


Basic Logic Constructs
Intermediate Nodes - Place Holders (for readability)
– If A or B then C.
– If Q and R then C.
– If S and not Q then C. A I1

B
R I2 … C

Q ƒ
[If A or B] „
I
S 3

or
[If Q and R]
or Í the “or” relationship is assumed and must be checked.
[If S and not Q]
then C. Copyright 2006 Bender RBT Inc. 38

Copyright 2006 Bender RBT Inc. 38


Basic Logic Constructs

Intermediate Nodes - Place Holders (continued)

Incorrect Correct
A A I1

B „ B
… X … … X
C C I2


D D I3

Each logical operator must result in a unique node.


Copyright 2006 Bender RBT Inc. 39

Copyright 2006 Bender RBT Inc. 39


Basic Logic Constructs
4. Nested Ifs
(Order of the Statements is Important)

If A Or B A
ERROR1
Then C ƒ
… C
If C And D ERROR2
B ƒ
Then E „ E
If E And F D ƒ
ERROR3

Then G „ G
Else Error3 F
Else Error2
Else Error1.
Copyright 2006 Bender RBT Inc. 40

Copyright 2006 Bender RBT Inc. 40


Basic Logic Constructs

4. Nested Ifs (continued)


Explicit Style
A ERROR1

… C ERROR2

ƒ
B
„ E ERROR3

ƒ
D
„ G

F
Copyright 2006 Bender RBT Inc. 41

Copyright 2006 Bender RBT Inc. 41


Basic Logic Constructs

4. Nested Ifs (continued)

A ERROR1 A

ERROR1
ƒ

… C
… C ERROR2
ERROR2
„ ƒ
ƒ B
B „ E
„ E D

D
ERROR 2: C True and D
ERROR 2: C True and D False; C False and D True;
False. C False and D False.
Copyright 2006 Bender RBT Inc. 42

Copyright 2006 Bender RBT Inc. 42


Basic Logic Constructs

4. Nested Ifs
(continued) A ‡
ERROR1

If A Or B
Then C … C ERROR2
Implicit „
If D Or E “and” B
ƒ
Then F F

Else Error2 D
Else Error1. …
I1
E
“ and” Implicit
In Specification

Copyright 2006 Bender RBT Inc. 43

Copyright 2006 Bender RBT Inc. 43


Basic Logic Constructs

5. Case Statement - Exhaustive ƒ C


A „

If [not A] and B then C. „ D


If A and B then D.
If A and [not B] then E. „ E
ƒ
If [not A] and [not B] then F. B „
ƒ
ƒ F

All possible cases are explicitly defined.


Copyright 2006 Bender RBT Inc. 44

Copyright 2006 Bender RBT Inc. 44


Basic Logic Constructs

5. Case Statement with Otherwise


A D

If A and B and C then D
E
If [not A] and B and C then E B „ ‡ G

If A and B and [not C] then F


Otherwise, G C ƒ „

Only some of the cases are explicitly defined.


Copyright 2006 Bender RBT Inc. 45

Copyright 2006 Bender RBT Inc. 45


Basic Logic Constructs

A given node should appear only once on a graph.


Incorrect - Correct -
ƒ A ƒ D
A D

A B „ E
„ E …
B C F

A
… F
C

Copyright 2006 Bender RBT Inc. 46

Copyright 2006 Bender RBT Inc. 46


Basic Logic Constructs

Common Mistake “Fallen Tree”

Vs.

Copyright 2006 Bender RBT Inc. 47

Copyright 2006 Bender RBT Inc. 47


Common Cases

1. State Machines
2. Looping Logic
3. Real Time Systems
4. Alternate Paths
5. Asynchronous Processing

Copyright 2006 Bender RBT Inc. 48

Copyright 2006 Bender RBT Inc. 48


Common Cases

1. State Machines State Machines with


without State Memory State Memory

C3 Si S1 S2
Si „ ƒ „
„ S3 C1
PREV.
S1 S2

S2 C2 „
C1 „
S3
C2

Copyright 2006 Bender RBT Inc. 49

Copyright 2006 Bender RBT Inc. 49


Common Cases
2. Looping Logic
Case 1:
For each customer with a checking account whose
loans are current and who have been customers for
5 years or more, then give them free checking.
Rules identical for each item processed.
Checking Account

Loans Current Free
Checking
Customer >=5 Years

(Looping Logic Implicit)


Copyright 2006 Bender RBT Inc. 50

Copyright 2006 Bender RBT Inc. 50


Common Cases
2. Looping Logic (continued)
Case 2:
Unique rules dependent on where in the loop you
are Usually First, On-Going, Last).
Example 1: Example 2:
A Do X
If First …

Others Process Do Next





If Last More End
B ƒ

Copyright 2006 Bender RBT Inc. 51

Copyright 2006 Bender RBT Inc. 51


Common Cases

3. Real Time Systems


Time factor is just a node.
If A occurs and B occurs within 1 second of A,
then C.
A Occurs

„ C

B < 1 Sec A

Copyright 2006 Bender RBT Inc. 52

Copyright 2006 Bender RBT Inc. 52


Common Cases
Stop
4. Alternative ƒ

Paths X
A1
A3
A5
A
A2
A4
B1
B3
B5
B
B2
B4
Copyright 2006 Bender RBT Inc. 53

Copyright 2006 Bender RBT Inc. 53


Common Cases
5. Asynchronous Processing with Sync Points
(Initial Sync Point)
X
A1
A3
A5
A
A2
A4
...
A7

B1
B3
.C.(Sync
A 6

. Point)
B
...
B5

B2
B4
Copyright 2006 Bender RBT Inc. 54

Copyright 2006 Bender RBT Inc. 54


Exercise 4-2

Draw the cause-effect graph for the following requirement:


1. Code 1 designates that Report 1 is printed. Code 2 designates
that Report 2 is printed. If both Code 1 and Code 2 are specified,
then Report 3 is also printed.

Copyright 2006 Bender RBT Inc. 55

Copyright 2006 Bender RBT Inc. 55


Exercise 4-2

Draw the cause-effect graph for the following requirement:


2. If it is year-end and the account is open and there is a positive
balance, then create a customer statement, create a government
statement, and send the customer a check for the interest earned
this year.

Copyright 2006 Bender RBT Inc. 56

Copyright 2006 Bender RBT Inc. 56


Exercise 4-2

Draw the cause-effect graph for the following requirements:


3. If the game is played and Bob has the day off, he will go to the
game. If the game is not played and Bob has the day off, he will go
for a hike. If the game is played and Bob does not have the day off,
he will listen to it on the radio. If the game is not played and Bob does
not have the day off, he will actually get some work done.

Copyright 2006 Bender RBT Inc. 57

Copyright 2006 Bender RBT Inc. 57


Exercise 4-2
Draw the cause-effect graph for the following
requirements:
4. If the Eagles and the Forty-Niners play, then I
will go to the game. If the Eagles play any other
team than the Forty-Niners, then I will watch the
game on TV. If the Forty- Niners play any other
team than the Eagles, then I will tape the game. If
neither the Eagles nor the Forty-Niners are
playing, then I will go for a hike.

Copyright 2006 Bender RBT Inc. 58

Copyright 2006 Bender RBT Inc. 58


Exercise 4-2

Draw the cause-effect graph for the following


requirements:
5. If the transaction code is either a 1, 2, or 3 it is valid. If
it is not valid display error message 1. If the account
status is either an A or B it is valid. If it is not valid
display error message 2. If the account balance is
numeric it is valid. If it is not numeric then display error
message 3. If the transaction code, account code, and
account balance are all valid, then process the
transaction; else reject the transaction.

Copyright 2006 Bender RBT Inc. 59

Copyright 2006 Bender RBT Inc. 59


Exercise 4-2

Draw the cause-effect graph for the following requirements:


6. If the transaction code is either a 1, 2, or 3 it is valid. If it
is not valid display error message 1 and reject the
transaction. Else (i.e., the transaction code is valid) if the
account status is either an A or B it is valid. If it is not valid
display error message 2 and reject the transaction. Else
(i.e., the account status is valid) if the account balance is
numeric it is valid. If it is not then display error message 3
and reject the transaction. If the transaction code, account
code, and account balance are all valid, then process the
transaction.

Copyright 2006 Bender RBT Inc. 60

Copyright 2006 Bender RBT Inc. 60


Exercise 4-2

Draw the cause-effect graph for the following requirements:


7. Cash flow predictions are made, in part, by accruing
expected income according to payment methods
associated with shipment to customers. For wholesale
customers, shipment of prepaid orders are accrued
immediately. COD and standard billing methods of
payment are accrued after fourteen days. Retail
customer shipments that are prepaid or COD are
accrued immediately, while standard billing is accrued
after fourteen days. Retail CODs are accrued at 80%
of the shipment value.

Copyright 2006 Bender RBT Inc. 61

Copyright 2006 Bender RBT Inc. 61


Exercise 4-2

Draw the cause-effect graph for the following requirements:


8. If you fax the memo and the line is busy, wait 1 minute
and retry. Do this until you get through or have retried 5
times. After 5 retries terminate the fax.

Copyright 2006 Bender RBT Inc. 62

Copyright 2006 Bender RBT Inc. 62


Exercise 4-2
9.
Case MODE-OF-BILLING
If it is a PREPAID-SHIPMENT
Then
ACCRUE_100%_IMMEDIATELY.
If it is a STANDARD-BILLING
Then
ACCRUE_100%_IN_14_DAYS.
If it is a COD-SHIPMENT and a WHOLESALE-CUSTOMER
Then
ACCRUE_100%_IN_14_DAYS.
If it is a COD-SHIPMENT and a RETAIL-CUSTOMER
Then
ACCRUE_80%_IMMEDIATELY.
Otherwise
No Other Cases Possible
EndCase.

Copyright 2006 Bender RBT Inc. 63

Copyright 2006 Bender RBT Inc. 63


Exercise 4-2
10. TAKE_ AN_ ORDER
BEGIN
Case
If B1-BUTTON pushed and B1-MESSAGE-AREA is not blank
Then
TAKE_A_ONE_SCOOP_ORDER.
If B2-BUTTON pushed and B2-MESSAGE-AREA is not blank
Then
TAKE_A_TWO_SCOOP_ORDER.
If B3-BUTTON pushed and B3-MESSAGE-AREA is not blank
Then
TAKE_A_TWO_SCOOP_SUNDAE_ORDER.
If B4-BUTTON pushed and B4-MESSAGE-AREA is not blank
Then
TAKE_A_THREE_SCOOP_SUNDAE_ORDER.
Otherwise (They pushed a button having no corresponding available product)
Display OPTION-NOT-AVAILABLE-MESSAGE in the
INFORMATION-MESSAGE-AREA.
Wait for customer to push RESET-BUTTON.
Set INFORMATION-MESSAGE-AREA to blank.
EndCase.
END
Copyright 2006 Bender RBT Inc. 64

Copyright 2006 Bender RBT Inc. 64


Exercise 4-2
11. SELECT_DISH
BEGIN
Case
If [(LARGE-DISH requested)
or (MEDIUM-DISH requested and MEDIUM-DISHES is empty)
or (SMALL-DISH requested and SMALL-DISHES is empty and
MEDIUM-DISHES is empty)]
Then
DISPENSE_ONE_LARGE_DISH.
If [(MEDIUM-DISH requested and MEDIUM-DISHES is not empty)
or (SMALL-DISH requested and SMALL-DISHES is empty and
MEDIUM-DISHES is not empty)]
Then
DISPENSE_ONE_MEDIUM_DISH.
If [SMALL-DISH requested and SMALL-DISHES is not empty]
Then
DISPENSE_ONE_SMALL_DISH.
Otherwise
UNABLE-TO-DISPENSE-A-DISH.
EndCase.
END

Copyright 2006 Bender RBT Inc. 65

Copyright 2006 Bender RBT Inc. 65


Exercise 4-2
12. State Transition Problem
HAN G UP

HAN G UP
Phone Connected
On Hook DIAL
CORRECT,
PICK NUM BER DIAL
NO DIAL UP PHONE ANSWERED NUM BER,
TONE, PHONE
HAN G DIAL IN USE
UP TONE Ready Busy
Phone To Call
Off Hook
DIAL
NUM BER,
DIAL NO ANSWER
HAN G UP INCORRECT Ringing
Wrong NUM BER,
Forever
ANSWERED
Number
HAN G UP

Copyright 2006 Bender RBT Inc. 66

Copyright 2006 Bender RBT Inc. 66


Exercise 4-3: Working with Poor
Requirements.

If neither Sally nor Sarah are going to the party then Harry will
not go either. If Sarah and John go, Harry will not go. If Sally
and Bob go, Harry will not go. Otherwise, Harry will go.

– This requirement is written as a set of negative


statements.
• Graph it as it is written.
• Re-write and re-graph it changing it to positive
statements without changing the logic.
– If Harry’s goal is to begin dating either Sally or Sarah,
does this specification meet his goals?
If not, correct it and re-graph it.
Copyright 2006 Bender RBT Inc. 67

Copyright 2006 Bender RBT Inc. 67


Exercise 4-2: Answers
1. Code 1 designates that Report 1 Code 1 Report 1
is printed. Code 2 designates that
Report 2 is printed. If both Code Code 2 Report 2

1 and Code 2 are specified, then
Report 3
Report 3 is also printed. Version 1

Code 1 Report 1
Report 1
Code 1
„ Report 3
„ Report 3
Code 2 Report 2 Code 2
Version 2 Report 2

Version 3
(less correct)

Copyright 2006 Bender RBT Inc. 68

Copyright 2006 Bender RBT Inc. 68


Exercise 4-2: Answers
2. If it is year-end and the account is open and
there is a positive balance, then create a
customer statement, create a government
statement, and send the customer a check for
the interest earned this year.
Year End Cust. Stmt.

I1
Account Open „ Govt. Stmt.

Positive Balance Check

Copyright 2006 Bender RBT Inc. 69

Copyright 2006 Bender RBT Inc. 69


Revised Answer
• 2

(Thanks to Joel Cohen – EDS)

Copyright 2006 Bender RBT Inc. 70

Copyright 2006 Bender RBT Inc. 70


Exercise 4-2: Answers
3. If the game is played and Bob has the day off, he will go to the
game. If the game is not played and Bob has the day off, he will go
for a hike. If the game is played and Bob does not have the day off,
he will listen to it on the radio. If the game is not played and Bob
does not have the day off, he will actually get some work done.
Game Played Go To Game

„ Listen On Radio
ƒ
ƒ

Day Off Go For Hike
„ƒ
ƒ
Actually Work

Copyright 2006 Bender RBT Inc. 71

Copyright 2006 Bender RBT Inc. 71


Exercise 4-2: Answers
4. If the Eagles and the Forty-Niners play, then I will go to the game. If
the Eagles play any other team than the Forty-Niners, then I will
watch the game on TV. If the Forty- Niners play any other team than
the Eagles, then I will tape the game. If neither the Eagles nor the
Forty-Niners are playing, then I will go for a hike.
Eagles Play Go To Game

Play Each Other „


ƒ Watch Game
On TV
ƒ
49ers Play „
Tape Game
„ ƒ
ƒ
Go For Hike

Copyright 2006 Bender RBT Inc. 72

Copyright 2006 Bender RBT Inc. 72


Copyright 2006 Bender RBT Inc. 73

Copyright 2006 Bender RBT Inc. 73


Exercise 4-2: Answers
5. If the transaction code is either a 1, 2, or 3 it is valid. If it is
not valid display error message 1. If the account status is
either an A or B it is valid. If it is not valid display error
message 2. If the account balance is numeric it is valid.
If it is not numeric then Error Msg1
display error message 3. 1 ‡ Valid Reject
If the transaction code, 2 Trans. Code

Transaction

account code, and
account balance are all 3 Error
A ‡ Msg2
valid, then process the
Process


transaction; else reject Valid Acct. Transaction
B
the transaction. Status

Acct. Bal.
Numeric
ƒ

Error M sg3
Copyright 2006 Bender RBT Inc. 74

Copyright 2006 Bender RBT Inc. 74


Alternative 1
• 5

Copyright 2006 Bender RBT Inc. 75

Copyright 2006 Bender RBT Inc. 75


Alternative 2
• 5

Copyright 2006 Bender RBT Inc. 76

Copyright 2006 Bender RBT Inc. 76


Alternative 3
• 5

Copyright 2006 Bender RBT Inc. 77

Copyright 2006 Bender RBT Inc. 77


Exercise 4-2: Answers
6. If the transaction code is either a 1, 2, or 3 it is valid. If it is not valid
display error message 1 and reject the transaction. Else (i.e., the
transaction code is valid) if the account status is either an A or B it is
valid. If it is not valid display error message 2 and reject the
transaction. Else (i.e., the account status is valid)
Error Reject
if the account balance is numeric Msg1 … Trans.
it is valid. If it is not then display 1 ‡ Error
error message 3 and reject the Msg2
transaction. If the transaction 2 …

code, account code, and Valid Valid
3 Trans. Account
account balance are all valid, Code Status
… Error
then process the transaction.

A Msg3
‡ I2
ƒ


I1 …
Process
Transaction
B Acct. Bal.
Numeric
Copyright 2006 Bender RBT Inc. 78

Copyright 2006 Bender RBT Inc. 78


Structure English – Peer Level If’s
If the Transaction-Code is either 1 or 2 or 3
5 Then
It is a Valid-Transaction-Code
Else
DISPLAY_THE_ERROR_MESSAGE (using Error-Message-1)

If the Account-Status is either A or B


Then
It is a Valid-Account-Status
Else
DISPLAY_THE_ERROR_MESSAGE (using Error-Message-2)

If the Account-Balance is Numeric


Then
It is a Valid-Account-Balance
Else
DISPLAY_THE_ERROR_MESSAGE (using Error-Message-3)

If there is a Valid-Transaction-Code and a Valid-Account-Status and


a Valid-Account-Balance
Then
PROCESS_THE_TRANSACTION
Else
REJECT_THE_TRANSACTION
Copyright 2006 Bender RBT Inc. 79

Copyright 2006 Bender RBT Inc. 79


Structured English – Nested If’s

6 If the Transaction-Code is either 1 or 2 or 3


Then
It is a Valid-Transaction-Code
If the Account-Status is either A or B
Then
It is a Valid-Account-Status
If the Account-Balance is numeric
Then
It is a Valid-Account-Balance
PROCESS_THE_TRANSACTION
Else
REJECT_THE_TRANSACTION
(using Error-Message-3)
Else
REJECT_THE_TRANSACTION (using Error-Message-2)
Else
REJECT_THE_TRANSACTION (using Error-Message-1)

Copyright 2006 Bender RBT Inc. 80

Copyright 2006 Bender RBT Inc. 80


Exercise 4-2: Answers
7. Cash flow predictions are made, in part, by accruing expected
income according to payment methods associated with shipment to
customers. Wholesale
For wholesale customers, …I2
shipment of prepaid orders … Accrue 100%
Immediately
are accrued immediately. Prepaid

I3
COD and standard billing
COD I1 I4 …
methods of payment are

accrued after fourteen days.
… Accrue 100%
Retail customer shipments In 14 Days
that are prepaid or COD Standard …
are accrued immediately, I5
while standard billing is
Accrue 80%

accrued after fourteen days.
Immediately
Retail CODs are accrued at Retail
80% of the shipment value.
Copyright 2006 Bender RBT Inc. 81

Copyright 2006 Bender RBT Inc. 81


Exercise 4-2: Answers

8. If you fax the Fax … Successful


memo and the ƒ
line is busy, wait 1 Busy
minute and retry.
1 Minute
… Retry
Do this until you
get through or ƒ

have retried 5
times. After 5

5 Retries Terminate
So Far
retries terminate
the fax. Version 1

Copyright 2006 Bender RBT Inc. 82

Copyright 2006 Bender RBT Inc. 82


Exercise 4-2: Answers

8. Fax … Successful

Busy
… Terminate


5 Retries Start Timer
So Far ƒ


Retry

Version 2 1 M inute

Copyright 2006 Bender RBT Inc. 83

Copyright 2006 Bender RBT Inc. 83


Exercise 4-2: Answers

9.
Case MODE-OF-BILLING
If it is a PREPAID-SHIPMENT Prepaid Accrue 100%
Then Immediately
ACCRUE_100%_IMMEDIATELY.
If it is a STANDARD-BILLING Standard Accrue 100%
Then … In 14 Days
ACCRUE_100%_IN_14_DAYS. COD …
If it is a COD-SHIPMENT and a WHOLESALE- I1
CUSTOMER
Then
ACCRUE_100%_IN_14_DAYS.
If it is a COD-SHIPMENT and a RETAIL-
CUSTOMER Wholesale
Then …
ACCRUE_80%_IMMEDIATELY. Retail Accrue 80%
Otherwise Immediately
No Other Cases Possible
EndCase.

Copyright 2006 Bender RBT Inc. 84

Copyright 2006 Bender RBT Inc. 84


Exercise 4-2: Answers
10. TAKE_ AN_ ORDER
BEGIN
Case
If B1-BUTTON pushed and B1-MESSAGE-AREA is not blank
Then
TAKE_A_ONE_SCOOP_ORDER.
If B2-BUTTON pushed and B2-MESSAGE-AREA is not blank
Then
TAKE_A_TWO_SCOOP_ORDER.
If B3-BUTTON pushed and B3-MESSAGE-AREA is not blank
Then
TAKE_A_TWO_SCOOP_SUNDAE_ORDER.
If B4-BUTTON pushed and B4-MESSAGE-AREA is not blank
Then
TAKE_A_THREE_SCOOP_SUNDAE_ORDER.
Otherwise (They pushed a button having no corresponding available product)
Display OPTION-NOT-AVAILABLE-MESSAGE in the
INFORMATION-MESSAGE-AREA.
Wait for customer to push RESET-BUTTON.
Set INFORMATION-MESSAGE-AREA to blank.
EndCase.
END
Copyright 2006 Bender RBT Inc. 85

Copyright 2006 Bender RBT Inc. 85


Exercise 4-2: Answers

10. B1-BUTTON ONE-


„ SCOOP
B1-MSG
TWO-
B2-BUTTON SCOOPS
„ RESET-HIT
B2-MSG
„ BLANK-MSG

B3-BUTTON UNAVAILABLE

B3-MSG SUNDAE-
TWO
B4-BUTTON
„ SUNDAE-
B4-MSG THREE

Copyright 2006 Bender RBT Inc. 86

Copyright 2006 Bender RBT Inc. 86


Exercise 4-2
11. SELECT_DISH
BEGIN
Case
If [(LARGE-DISH requested)
or (MEDIUM-DISH requested and MEDIUM-DISHES is empty)
or (SMALL-DISH requested and SMALL-DISHES is empty and
MEDIUM-DISHES is empty)]
Then
DISPENSE_ONE_LARGE_DISH.
If [(MEDIUM-DISH requested and MEDIUM-DISHES is not empty)
or (SMALL-DISH requested and SMALL-DISHES is empty and
MEDIUM-DISHES is not empty)]
Then
DISPENSE_ONE_MEDIUM_DISH.
If [SMALL-DISH requested and SMALL-DISHES is not empty]
Then
DISPENSE_ONE_SMALL_DISH.
Otherwise
UNABLE-TO-DISPENSE-A-DISH.
EndCase.
END

Copyright 2006 Bender RBT Inc. 87

Copyright 2006 Bender RBT Inc. 87


Exercise 4-2: Answers

11.


ƒ „

ƒ „
„ ‡

ƒ
ƒ

Copyright 2006 Bender RBT Inc. 88

Copyright 2006 Bender RBT Inc. 88


Exercise 4-2: Answers
12. State Transition Problem
HAN G UP

HAN G UP
Phone Connected
On Hook DIAL
CORRECT,
PICK NUM BER DIAL
NO DIAL UP PHONE ANSWERED NUM BER,
TONE, PHONE
HAN G DIAL IN USE
UP TONE Ready Busy
Phone To Call
Off Hook
DIAL
NUM BER,
DIAL NO ANSWER
HAN G UP INCORRECT Ringing
Wrong NUM BER,
Forever
ANSWERED
Number
HAN G UP

Copyright 2006 Bender RBT Inc. 89

Copyright 2006 Bender RBT Inc. 89


Exercise 4-2: Answers
12. State Transition Problem

I1

Copyright 2006 Bender RBT Inc. 90

Copyright 2006 Bender RBT Inc. 90


Exercise 4-3: Working with Poor
Requirements.

If neither Sally nor Sarah are going to the party


then Harry will not go either.
If Sarah and John go, Harry will not go.
If Sally and Bob go, Harry will not go.
Otherwise, Harry will go.

Copyright 2006 Bender RBT Inc. 91

Copyright 2006 Bender RBT Inc. 91


Exercise 4-3: Answers
If neither Sally nor Sarah are
A
John No Harry 1 going to the party then Harry will
… E not go either. If Sarah and John
go, Harry will not go. If Sally and
B No Bob go, Harry will not go.
Sarah Harry 2 Otherwise, Harry will go.
F
‡ ‡ H
Harry Goes
C
Sally

G
No Harry 3
D
Bob Version 1

Copyright 2006 Bender RBT Inc. 92

Copyright 2006 Bender RBT Inc. 92


Exercise 4-3: Answers
If either Sarah or Sally goes to the party
And
Sarah does not go with John
And
Sally does not go with Bob
Then, Harry will go to the party.
Otherwise, Harry will not go.

Copyright 2006 Bender RBT Inc. 93

Copyright 2006 Bender RBT Inc. 93


Exercise 4-3: Answers

If Sarah goes without John


Or
Sally goes without Bob
Then, Harry will go to the party.
Otherwise, Harry will not go.

Copyright 2006 Bender RBT Inc. 94

Copyright 2006 Bender RBT Inc. 94


Exercise 4-3: Answers

If neither Bob nor John go to the party


And
Either Sally or Sarah, but not both, go to
the party
Then, Harry will go to the party.
Otherwise, Harry will not go.

Copyright 2006 Bender RBT Inc. 95

Copyright 2006 Bender RBT Inc. 95


Cause-Effect Graphing
Strategy

• Identify Graphable Units.


• Assign Similar Functions to the Same Tester to
Graph.
• Compare Graphs for Similar Functions
– Look for anomalies in the patterns.
• Exploit Opportunities for Generic Graphs.

Copyright 2006 Bender RBT Inc. 96

Copyright 2006 Bender RBT Inc. 96


Generic Graphs
GUI Select
Item
Click On Item
Highlight Item

Arrows To Item

Click On Item Again
Hit Enter …
I1 Perform
OK Button Hot Key … Selected
Option

Double Click

Copyright 2006 Bender RBT Inc. 97

Copyright 2006 Bender RBT Inc. 97


Cause-Effect Graphing Summary

Graphing Ensures that the Tester


– Identifies all variables
– Resolves aliases within/across processes
– Knows the allowable states of the variables
i.e., Domain and Relational Rules
– Knows which variables are mandatory versus optional
– Understands the precedence relationships
e.g., Sequence of Editing
– Understands the Boundary Conditions
– Identifies implicit information and gets it clarified
– Knows which output variables are observable

There is nothing a tester needs to graph that is not


required to test - regardless of the Test Methodology.
Copyright 2006 Bender RBT Inc. 98

Copyright 2006 Bender RBT Inc. 98


Cause-Effect Graphing Summary

• There are only a limited set of basic constructs to learn:


 Simple
 Compound If
 Peer Level Ifs
 Nested Ifs
 Case Statement

• The clearer the requirements, the easier it is to graph.

• Consistent standards (e.g., GUI interfaces) allow canned


models to be used.

• You will find defects during the cause-effect graphing


phase.
Copyright 2006 Bender RBT Inc. 99

Copyright 2006 Bender RBT Inc. 99


The RBT Process
1. Validate Requirements Against Objectives
2. Apply Scenarios Against Requirements
3. Perform Initial Ambiguity Review
4. Perform Domain Expert Reviews
5. Create Cause-Effect Graph
6. Logical Consistency Check and Test Case Design by RBT
7. Review of Test Cases by Requirements Author
8. Validate Test Cases with Users/Domain Experts
9. Review of Test Cases by Developers
10. Walk Test Cases Through Design
11. Walk Test Cases Through Code
12. Verify Code Against Test Cases Designed from Requirements

Copyright 2006 Bender RBT Inc. 100

Copyright 2006 Bender RBT Inc. 100

You might also like