You are on page 1of 30

Decision Table-

based Testing
Decision Table-based testing
▪Uses logical decisions
▪Includes conditions and describes several different
scenarios
▪Describes impossible combinations of input values
▪May not be obvious for all problems

2
Decision Table
stub entries

conditions condition entries (rules)

actions action entries

3
Explanation
The top left portion of the table describes conditions
◦ One line per input variable
For each line in the top left portion, the top right
portion describes whether the condition is true or
false
Each line in the bottom left portion describes an
action
Each vertical column in bottom right portion
indicates what actions to be taken when the
corresponding conditions in the top right portion
are matching

4
Example - login
▪User provides two inputs – username and password
▪Both inputs are validated for format and existence in the data store.

▪Action
▪ Invalid entry – may be incorrect format or the parameter does not exist
▪ Valid entry – the user is allowed to login
Conditions 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2

Username format T T T T T T T T T T T T T T T T F F F F F F F F F F F F F F F F
is correct
Username T T T T T T T T F F F F F F F F T T T T T T T T F F F F F F F F
matches with an
entry in data store
Password format T T T T F F F F T T T T F F F F T T T T F F F F T T T T F F F F
is correct
Password T T F F T T F F T T F F T T F F T T F F T T F F T T F F T T F F
matches with an
entry in data store
Username and T F T F T F T F T F T F T F T F T F T F T F T F T F T F T F T F
password both
match an entry in
data store
Actions

Login X

Error message X X X X X X X X X

Impossible X X X X X X X X X X X X X X X X X X X X X X

6
Decision-table Example
a customer is granted a discount based on the
level of customer reward, geographic region,
and the product suite they are receiving.
If a customer’s reward is silver, region is west, promotion is product A, then he/she will get a discount of 5%.
If a customer’s reward is silver, region is west, promotion is product B, then he/she will get a discount of 3%.
If a customer’s reward is silver, region is west, promotion is product C, then he/she will get a discount of 10%.
If a customer’s reward is silver, region is east, promotion is product A, then he/she will get a discount of 5%.
If a customer’s reward is silver, region is east, promotion is product C, then he/she will get a discount of 5%.
If a customer’s reward is silver, region is east, promotion is product A, then he/she will get a discount of 5%.
If a customer’s reward is gold, region is east, promotion is product B, then he/she will get a discount of 5%.
If a customer’s reward is gold, region is east, promotion is product C, then he/she will get a discount of 5%.
Another Example
Given three integers a, b and c representing the sides of a triangle, and the function

String typeOfTrinagle (int a, int b, int c)

that determines what type of triangle the inputs represent, generate test cases for the
function using decision table method. Notice that the three integers may not form a triangle.
Use the following conditions to determine whether or not they represent a triangle.

a + b > c AND b + c > a AND c + a > b

This example is given in Paul Jorgensen’s book.

9
Conditions 1 2 3 4 5 6 7 8 9 10 11

a < b + c? F T T T T T T T T T T
b < c + a? - F T T T T T T T T T
c < a + b? - - F T T T T T T T T
a = b? - - - T T T T F F F F
b = c? - - - T T F F T T F F
c = a? - - - T F T F T F T F
Actions
Not a triangle X X X
Scalene X
Isosceles X X X X
Equilateral X
Impossible X X X

‘-’ represents a DON’T CARE value for a condition

10
Robust testing

Notice that there are no constraints on the type of input variables (integer,
double, character, etc.) and there are no constraints on zero or negative
values of the input variables (which do not make sense for a triangle)

Adding these constraints will exponentially increase the table size and make
it difficult to use
Generating test cases
• One test case per column in the truth table
• No test cases for “impossible” situations
• Every don’t care condition generates two test cases, one for ‘T’ and one for ‘F’
◦ Don’t care entry
◦ The condition is irrelevant
◦ The condition does not apply

• Total number of test cases will be less than or equal to the number of columns in the truth
table
• Make sure that all possible outcomes/actions are covered in the test cases

12
Test cases
Test case No. a b c Expected
output
1 10 5 5 Not a triangle
2 5 10 5 Not a triangle
3 5 5 10 Not a triangle
4 10 10 10 Equilateral
triangle or
isosceles
triangle
5 10 10 15 Isosceles
triangle
6 10 15 15 Isosceles
triangle
7 15 10 15 Isosceles
triangle
8 10 15 20 Scalene
triangle

13
Decision Table for f(x1,x2)
a<= X1 <=b T T F F

c<= X2 <=d T F T F

Compute y X

Output error X X X

14
Explanation
When both input values x1 and x2 are within their ranges (defined by the
first column in top right portion), compute y value ( described by the action
column in bottom right portion).
In all other situations, output an error message

15
Decision Table with “don’t cares”

a<= X1 <=b T - F F

c<= X2 <=d T F - F

Compute y X

Output error X X X

“-” indicates “don’t care”

16
Decision Table for f(x1,x2) – Extended Version
1

x1 < a T F F F F
x1 = a F T F F F
a < x1 <b F F T F F
x1=b F F F T F
x1>b F F F F T
c<= X2 <=d - T T T -

Compute y X X X

Output error X X

Exercise: Split the conditions for x2 and expand the table

17
Decision Tables
A decision table guarantees a form of complete testing
◦ we consider every possible combination of condition values.
◦ Decision table is declarative

Limited entry decision table – all the conditions are binary


(true /false, yes/no, 0/1)
Extended entry decision table – conditions are allowed to
have several values.

18
Decision Table-based Testing
Identify test cases from decision table
◦Consider conditions as input
◦Consider actions as output
◦Rules are test cases

19
Develop a decision table
Decision tables provide a notation that translates conditions and actions
into a tabular form.
Steps to develop a decision table:
◦ List all actions that can be associated with a specific function (or module)
◦ List all conditions( or decisions made) during execution of the procedure
◦ Associate specific sets of conditions with specific actions, eliminating
impossible combinations; alternatively, develop every possible permutation
of conditions.
◦ Define rules by indicating what action(s) occurs for a set of conditions.

20
Decision Tables
The choice of conditions can greatly expand the size of a
decision table.
◦ When conditions refer to equivalence classes
◦ Actions are “treatment”
◦ NextDate: mutually excusive among conditions

Don’t care entry


◦ Without don’t care entry, rule counts as 1
◦ With don’t care entry, double the rules.

21
Decision Tables
Complete the decision table:
Redundancy – remove the repetition
Consistency – when don’t care entry is used in the decision table and causes
the inconsistency, we should take care of the entry.

22
Another example
Generate test cases for the following problem using
decision-table method:
◦ A student is required to take three exams, for course A, course B and a
practicum for course B (let us call it course C).
◦ The student will get a pass if he/she gets 50% or more in each of the
exams.
◦ The student will get a pass if he/she gets 50% or more in A and B, and
gets an average of 65% in B and C together.
◦ The student will get a pass if he/she gets an average of 75% in all the
three courses put together.
◦ The student will fail otherwise.

23
Conditions
Let A, B and C represent marks in courses A, B
and C respectively.
◦There are five conditions:
◦ A >= 50
◦ B >= 50
◦ C >= 50
◦ (A+B)/2 >= 65
◦ (A+B+C)/3 >= 75

24
Actions
There are two possible actions
oPass
oFail
oImpossible

25
Decision table
Conditions
A >= 50 T T T T T T T T T T T T T T T T
B >= 50 T T T T T T T T F F F F F F F F
C >= 50 T T T T F F F F T T T T F F F F
(B+C)/2 >= 65 T T F F T T F F T T F F T T F F

(A+B+C)/3 >= 75 T F T F T F T F T F T F T F T F

Actions
Pass x x x x x x x x x
Fail x x x x
Impossible x x x

26
Decision table (continued)
Conditions
A >= 50 F F F F F F F F F F F F F F F F
B >= 50 T T T T T T T T F F F F F F F F
C >= 50 T T T T F F F F T T T T F F F F
(B+C)/2 >= 65 T T F F T T F F T T F F T T F F

(A+B+C)/3 >= 75 T F T F T F T F T F T F T F T F

Actions
Pass x x
Fail x x x x x x x
Impossible x x x x x x x

27
Simplified Decision Table
Conditions
A >= 50 T T - T - F F F -
B >= 50 T T - T F - F - F
C >= 50 T - - - - - - F F
(B+C)/2 >= 65 - T - F - - - - -
(A+B+C)/3 >= 75 - - T F F F T T T
Actions
Pass x x x
Fail x x x
Impossible x x x

28
Advantages of Decision table method

Covers most of the possible cases


◦ Easy to visualize the completeness of the test cases
Describe logical relationships between inputs
◦ Something that is missing in boundary value analysis and equivalence
class testing
Possible to identify impossible combinations of inputs
◦ A column for which no action is specified
Possible to identify inconsistent combinations of inputs
◦ Two identical condition entries leading to different action entries

29
Limitation
Decision-table method is useful for those applications
that include several dependent relationships among
the input parameters. For simple data-oriented
applications that typically perform operations such as
adding, deleting and modifying entries, decision-table
method is not appropriate.

30

You might also like