Arunkumar Khannur's Software Testing Knowledge Center
   
 

10.2. Decision Table based Testing

In Requirements-based Test Design, we use Decision Tables as intermediate step before writing test cases to test functionality of the system under test. Here using Decision tables, we represent all possible conditions. When we execute possible conditions we expect a specific action to be taken by the system. In case of a failure to exhibit expected action, it is quite indicative that a logic is missing. Thus, using Decision Tables we can easily track a set of conditions and corresponding to which actions.

In Decision Table based Testing, steps we follow include:
  • Develop Decision Table
  • Design Test Cases
Following sections discuss on these steps.

10.2.1. About Decision Table
Decision tables are useful to model complicated logic. They are precise and compact representations and are very useful in modeling statements like if-then-else and switch-case statements. They associate conditions with actions to perform. But, unlike the control structures found in traditional programming languages, decision tables can associate many independent conditions with several actions in an elegant way.

A decision table is a table composed of rows and columns, separated into four separate quadrants.
Conditions Condition Alternatives
Actions Action Entries

The upper left quadrant contains the conditions. The upper right quadrant contains the condition rules or alternatives. The lower left quadrant contains the actions to be taken and the lower right quadrant contains the action rules.

10.2.2. Developing Decision Tables
In order to build decision tables, first we need to determine the maximum size of the table, then we have to eliminate any impossible situations, inconsistencies, or redundancies, and finally we need to simplify the table as much as possible. Following are tips to develop decision tables, which when followed give a decision table.
  1. Study the given Specification and determine the number of conditions that may affect the decision. Remove any conditions that repeat. Once we arrive at this list of non-repeatable conditions (that is conditions that are mutually exclusive), we have to record all these conditions as rows in the top left half of the decision table.
  2. Determine the number of possible actions that can be taken. This becomes the number of rows in the lower left half of the decision table.
  3. Determine the number of condition alternatives for each condition. In the simplest form of decision table, there would be two alternatives (Y or N) for each condition. In an extended-entry table, there may be many alternatives for each condition
  4. Then we have to calculate the maximum number of columns in the decision table by calculating number of conditions raise to the number of alternatives. If there were three conditions and two alternatives (Y or N) for each of the conditions, there would be eight alternatives. This is because, the condition rules are yes or no, therefore the number of possible condition rules are 2 alternatives for condition 1 x 2 alternatives for condition 2 x 2 alternatives for condition
    3 or 23 = 8.
  5. Fill in the condition alternatives. Start with the first condition and divide the number of columns by the number of alternatives for that condition. In the foregoing example, there are three columns and two alternatives (Y and N), so eight divided by two is four. Then choose one of the alternatives and write Y in all of the four columns. Finish by writing N in the remaining four columns as follows:
    Condition1: YYYYNNNN
    Repeat this for each condition using a subset of the table:
    Y Y Y Y N N N N
    Y Y N N
    y N
    and continue the pattern for each condition
    Y Y Y Y N N N N
    Y Y N N Y Y N N
    y N Y N Y N Y N
  6. Complete the table by inserting a √ where rules suggest certain actions
  7. Combine rules where it is apparent that an alternative does not make a difference in the outcome;
    for example:
    Condition 1 YY
    Condition 2 YN
    Condition 3 YY
    Action 1 √ √
    can be expressed as
    Condition 1 Y
    Condition 2 Y/N
    Condition 3 Y
    Action 1 √ √
  8. Check the table for any impossible situations, contradictions, redundancies.
  9. Rearrange the conditions and actions (or even rules) to make the decision table more understandable.

10.2.3. An Example on Creating Decision Table
Write test cases for fixed deposit interest calculations with following conditions.
Deposite
Amount
0-90 Days

90 Days-
1 Years

1 Years-
3 Years
3 years -
5 years
Above
5 years
a <= 5000 5% 5.5% 6% 6.5% 7%
b 5001 to
50000
5.5% 6% 6.5% 7% 7.5%
c 50001 to
100000
6.5% 7% 7.5% 8% 8.5%
d 100001 to
500000
7.5% 8% 8.5% 9% 9.5%

The branch cannot accept more than 5,00,000 deposit in single name.
The minimum balance is Rs 1000/-

For this problem, the conditions to check are agreed involve, three variable, viz., Deposit Amount, Duration, Rate of Interest. So we have to develop many Decision Tables.

In the first step, we have convert three dimensional problem (since three variables are involved) into two dimensional problem so as to represent in Decision Table form.

10.2.4. An Example on Creating Decision Table
Problem specification for which we want to arrive at Decision Table which is an intermediate step before writing test cases for fixed deposit interest calculations involve following rules.
Deposite
Amount
0-90 Days

90 Days-
1 Years

1 Years-
3 Years
3 years -
5 years
Above
5 years
a <= 5000 5% 5.5% 6% 6.5% 7%
b 5001 to
50000
5.5% 6% 6.5% 7% 7.5%
c 50001 to
100000
6.5% 7% 7.5% 8% 8.5%
d 100001 to
500000
7.5% 8% 8.5% 9% 9.5%
e. The branch can not accept more than 500000 deposite in single name
f. The minimum balance is Rs. 1000/-

For this problem, the conditions to check are agreed involve, three variable, viz., Deposit Amount, Duration, Rate of Interest. So we have to develop many Decision Tables.

In the first step, we have convert three dimensional problem (since three variables are involved) into two dimensional problem so that we can represent it in Decision Table form. In order to do this, we analyze the problem and understand that- Deposit Amount is having 4 combinations; Duration is having 5 combinations; and Rate of Interest is having 5 combinations. Thus we take each Deposit Amount and develop Decision Table as follows:

First we take, for Deposit Amount between 1000 to <=5000.
Here the conditions are as follows:
Duration of Deposit is 0 to <=90 days
Duration of Deposit is 90 days to <=1 year
Duration of Deposit is 1 year to <=5 years
Duration of Deposit is Above 5 years The possible actions that could be taken are agreed as:
  • Calculate Interest at 5%
  • Calculate Interest at 5.5%
  • Calculate Interest at 6%
  • Calculate Interest at 7%

Using the rules above construct a decision table showing all possible combinations of alternatives.

The condition rules are yes or no, therefore the number of possible condition rules are 2 alternatives for condition 1 x 2 alternatives for condition 2 x 2 alternatives for condition 3 x 2 alternatives for condition 4 or 24 = 16
 
 
Khannur's Book
Arunkumar Khannur, Software Testing - Techniques and Applications, Published by Pearson Publications, 2011 (ISBN:978-81-317-5836-6; Pages:341 + xxii)
Follow Khannur
         
Khannur's Company
ISQT Process & Consulting Services Pvt. Ltd., Bangalore, INDIA
Khannur's Software Testing Forum
STEP-AUTO Forum
 Contact Khannur
ISQT Process & Consulting Services Pvt. Ltd.
#732, 1st Floor, 12th Main,
3rd Block, Rajajinagar,
Bangalore - 560010, INDIA
Phone: +91 80 23012511
URL: www.isqtinternational.com
Email: khannur@isqtinternational.com
Skype: arun.isqt