7 - Cause Effect Graph Based Testing
7 - Cause Effect Graph Based Testing
2
Cause-Effect Graphing (Contd..)
The graph allows selection of various
combinations of input values as tests.
3
Cause-Effect Graphing (Contd..)
A cause is any condition in the requirements that may effect
the program output.
4
Cause-Effect Graphing (Contd..)
An effect need not be an “output” visible to the user of
the program.
5
Example
Consider the requirement “Dispense food only
when the DF switch is ON”
◦ Cause is “DF switch is ON”.
◦ Effect is “Dispense food”.
7
Cause and Effect Graphs
8
Cause and Effect Graphs
Convert the graph to a decision
table:
◦ each column of the decision table
corresponds to a test case for
functional testing.
9
Steps to create cause-effect graph
Study the functional requirements.
Mark and number all causes and
effects.
Numbered causes and effects:
◦ become nodes of the graph.
10
Steps to create cause-effect graph
Draw causes on the LHS
Draw effects on the RHS
Draw logical relationship between
causes and effects
◦ as edges in the graph.
Extra nodes can be added
◦ to simplify the graph
11
Drawing Cause-Effect Graphs
A B
If A then B
A
C
B
If (A and B)then C
12
Drawing Cause-Effect Graphs
A
C
B
If (A or B)then C
A
C
B
If (not(A and B))then
C
13
Drawing Cause-Effect Graphs
A
C
B
If (not (A or B))then C
A B
If (not A) then B
14
Cause effect graph- Example
A water level monitoring system
◦ used by an agency involved in flood control.
◦ Input: level(a,b)
a is the height of water in dam in meters
b is the rainfall in the last 24 hours in cms
15
Cause effect graph- Example
Processing
◦ The function calculates whether the level is
safe, too high, or too low.
Output
◦ message on screen
level=safe
level=high
invalid syntax
16
Cause effect graph- Example
We can separate the requirements
into 5 causes:
17
Cause effect graph- Example
◦ or safe.
19
Cause effect graph- Example
Three effects
◦ level = safe
◦ level = high
◦ invalid syntax
20
Cause effect graph- Example
1 10
E3
2 11
3 E1
4
E2
5
21
Cause effect graph- Decision table
Test 1 Test 2 Test 3 Test 4 Test 5
Cause 1 I I I S I
Cause 2 I I I X S
Cause 3 I S S X X
Cause 4 S I S X X
Cause 5 S S I X X
Effect 1 P P A A A
Effect 2 A A P A A
Effect 3 A A A P P
2
Cause effect graph- Example
Put a row in the decision table for
each cause or effect:
◦ in the example, there are five rows
for causes and three for effects.
23
Cause effect graph- Example
The columns of the decision table
correspond to test cases.
Define the columns by examining
each effect:
◦ list each combination of causes that can
lead to that effect.
24
Cause effect graph- Example
We can determine the number of
columns of the decision table
◦ by examining the lines flowing into the
effect nodes of the graph.
25
Cause effect graph- Example
Theoretically
we could have
generated 25=32 test cases.
◦ Using cause effect graphing technique
reduces that number to 5.
26
Cause effect graph
Not practical for systems which:
◦ include timing aspects
◦ feedback from processes is used for
some other processes.
27
Procedure used for the generation of tests
Identify causes and effects by reading the
requirements. Each cause and effect is assigned a
unique identifier. Note that an effect can also be a
cause for some other effect.
not C implies Ef
C implies Ef
C Ef C Ef
C2 ^ Ef v Ef
C3 C2
30
Constraints amongst causes (E,I,O,R)
Constraints show the relationship between the causes.
Exclusive (E)
Inclusive (I)
Requires (R)
One and only one (O)
C1 C1
E I
C2
C2
C3
One and only one, of C1 and C2
C1 requires C2
C1
C1 O
R
C2 C2
31
Constraints amongst causes (E,I,O,R)
Exclusive (E) constraint between three causes C1, C2
and C3 implies that exactly one of C1, C2, C3 can be
true.
Inclusive (I) constraint between two causes C1 and
C2 implies that at least one of the two must be
present.
Requires (R) constraint between C1 and C2 implies
that C1 requires C2.
One and only one (O) constraint models the
condition that one, and only one, of C1 and C2 must
hold.
32
Possible values of causes constrained by
E, I, R,O
A 0 or 1 under a cause implies that the
corresponding condition is, respectively, false and
true.
The arity of all constraints, except R, is greater than
or equal to 2, i.e., all except the R constraint can be
applied to two or more causes; the R constraint is
applied to two causes.
A condition that is false (true) is said to be in the
“0-state” (1 state).
Similarly, an effect can be “present” (1 state) or
“absent” (0 state).
33
Possible values of causes constrained by E, I, R,O
Masking (M)
35
Steps for generating test cases using Cause-Effect Graph
Identification of all
causes and effects
Apply constraints, if
any
37
Creating Cause-Effect Graph
The cause-effect graph is constructed to
◦ express the relationships extracted from the
requirements.
38
Another example
Consider the example of keeping the record of marital
status and number of children of a citizen.
40
Answer
c1 e1
E v ^
c2 e2
R
c3 e3
41
Decision Table from cause-effect graph
Each column of the decision table represents a combination
of input values, and hence a test.
There is one row for each condition and effect.
Thus the table decision table can be viewed as an N X M
matrix with
◦ N being the sum of the number of conditions and effects and
◦ M the number of tests.
Each entry in the decision table is a 0 or 1
◦ depending on whether or not the corresponding condition is false or
true, respectively.
For a row corresponding to an effect, an entry is 0 or 1
◦ if the effect is not present or present, respectively.
42
Test generation from a decision table
Test generation from a decision table is relatively forward.
Each column in the decision table generates at least one test
input.
Note that each combination might be able to generate more
than one test when a condition in the cause-effect graph can
be satisfied in more than one way.
For example, consider the following cause:
C: x<99
The condition above can be satisfied by many values such as
x=1 and x=49.
Also, C can be made false by many values of x such as x=100
and x=999.
Thus, one might have a choice of values of input variables while
generating tests using columns from a decision table
43
Example
A tourist of age greater than 21 years and having a
clean driving record is supplied a rental car.
A premium amount is also charged if the tourist is
on business,
Otherwise, it is not charged.
If the tourist is less than 21 year old, or does not
have a clean driving record,
◦ The system will display the following message: “Car cannot
be supplied”.
44
Answer
Causes are
◦ c1: Age is over 21
◦ c2: Driving record is clean
◦ c3: Tourist is on business
Effects are
◦ e1: Supply a rental car without premium charge
◦ e2: Supply a rental car with premium charge
◦ e3: Car cannot be supplied
c1 e1
^ ^
c2 ^ e2
c3 e3
45
Decision Table and Test Cases
1 2 3 4
c1: Over 21? F T T T
c2: Driving record clean? - F T T
c3: On business? - - F T
e1: Supply a rental car without premium charge X
e2: Supply a rental car with premium charge X
e3: Car cannot be supplied X X
47
Answer
Causes are:
◦ c1: side “a” is less than the sum of sides “b” and “c”.
◦ c2: side “b” is less than the sum of sides “a” and “c”.
◦ c3: side “c” is less than the sum of sides “a” and “b”.
◦ c4: square of side “a” is equal to the sum of squares of sides “b” and “c”.
◦ c5: square of side “a” is greater than the sum of squares of sides “b” and “c”.
◦ c6: square of side “a” is less than the the sum of squares of sides “b” and “c”.
Effects are:
◦ e1: Invalid triangle
◦ e2: Right angle triangle
◦ e3: Obtuse angled triangle
◦ e4: Acute angled triangle
◦ e5: Impossible stage
48
Cause-Effect Graph
c1
c2 v e1
c3
^
c4 e2
^
E c5 e3
^
c6 e4
^
e5
49
Decision Table
1 2 3 4 5 6 7 8 9 10 11
c1: a<b+c F T T T T T T T T T T
c2: b<a+c - F T T T T T T T T T
c3: c<a+b - - F T T T T T T T T
c4: a2=b2+c2 - - - T T T T F F F F
c5: a2>b2+c2 - - - T T F F T T F F
c6: a2<b2+c2 - - - T F T F T F T F
e5: Impossible X X X X X
50
Thank You
51