Decision Table Testing (Example)

What is Decision Table Testing?

Decision table testing is a software testing technique used to test system behavior for different input combinations. This is a systematic approach where the different input combinations and their corresponding system behavior (Output) are captured in a tabular form. That is why it is also called as a Cause-Effect table where Cause and effects are captured for better test coverage.

A Decision Table is a tabular representation of inputs versus rules/cases/test conditions. It is a very effective tool used for both complex software testing and requirements management. A decision table helps to check all possible combinations of conditions for testing and testers can also identify missed conditions easily. The conditions are indicated as True(T) and False(F) values.

Let’s learn with an example.

Example 1: How to make Decision Base Table for Login Screen

Let’s create a decision table for a login screen.

Decision Base Table for Login Screen

The condition is simple if the user provides the correct username and password the user will be redirected to the homepage. If any of the input is wrong, an error message will be displayed.

Conditions Rule 1 Rule 2 Rule 3 Rule 4
Username (T/F) F T F T
Password (T/F) F F T T
Output (E/H) E E E H

Legend:

  • T – Correct username/password
  • F – Wrong username/password
  • E – Error message is displayed
  • H – Home screen is displayed

Interpretation:

  • Case 1 – Username and password both were wrong. The user is shown an error message.
  • Case 2 – Username was correct, but the password was wrong. The user is shown an error message.
  • Case 3 – Username was wrong, but the password was correct. The user is shown an error message.
  • Case 4 – Username and password both were correct, and the user navigated to the homepage

While converting this to a test case, we can create 2 scenarios,

  • Enter the correct username and correct password and click on login, and the expected result will be the user should be navigated to the homepage

And one from the below scenario

  • Enter wrong username and wrong password and click on login, and the expected result will be the user should get an error message
  • Enter correct username and wrong password and click on login, and the expected result will be the user should get an error message
  • Enter wrong username and correct password and click on login, and the expected result will be the user should get an error message

As they essentially test the same rule.

Example 2: How to make Decision Table for Upload Screen

Now consider a dialogue box that will ask the user to upload a photo with certain conditions like –

  1. You can upload only ‘.jpg’ format image
  2. file size less than 32kb
  3. resolution 137*177.

If any of the conditions fails the system will throw a corresponding error message stating the issue and if all conditions are met photo will be updated successfully

Make Decision Table for Upload Screen

Let’s create the decision table for this case.

Conditions Case 1 Case 2 Case 3 Case 4 Case 5 Case 6 Case 7 Case 8
Format .jpg .jpg .jpg .jpg Not .jpg Not .jpg Not .jpg Not .jpg
Size Less than 32kb Less than 32kb >= 32kb >= 32kb Less than 32kb Less than 32kb >= 32kb >= 32kb
resolution 137*177 Not 137*177 137*177 Not 137*177 137*177 Not 137*177 137*177 Not 137*177
Output Photo uploaded Error message resolution mismatch Error message size mismatch Error message size and resolution mismatch Error message for format mismatch Error message format and resolution mismatch Error message for format and size mismatch Error message for format, size, and resolution mismatch

For this condition, we can create 8 different test cases and ensure complete coverage based on the above table.

  1. Upload a photo with format ‘.jpg’, size less than 32kb and resolution 137*177 and click on upload. Expected result is Photo should upload successfully
  2. Upload a photo with format ‘.jpg’, size less than 32kb and resolution not 137*177 and click on upload. Expected result is Error message resolution mismatch should be displayed
  3. Upload a photo with format ‘.jpg’, size more than 32kb and resolution 137*177 and click on upload. Expected result is Error message size mismatch should be displayed
  4. Upload a photo with format ‘.jpg’, size more than equal to 32kb and resolution not 137*177 and click on upload. Expected result is Error message size and resolution mismatch should be displayed
  5. Upload a photo with format other than ‘.jpg’, size less than 32kb and resolution 137*177 and click on upload. Expected result is Error message for format mismatch should be displayed
  6. Upload a photo with format other than ‘.jpg’, size less than 32kb and resolution not 137*177 and click on upload. Expected result is Error message format and resolution mismatch should be displayed
  7. Upload a photo with format other than ‘.jpg’, size more than 32kb and resolution 137*177 and click on upload. Expected result is Error message for format and size mismatch should be displayed
  8. Upload a photo with format other than ‘.jpg’, size more than 32kb and resolution not 137*177 and click on upload. Expected result is Error message for format, size and resolution mismatch should be displayed

Why Decision Table Testing is Important?

Decision Table Testing is Important because it helps to test different combinations of conditions and provides better test coverage for complex business logic. When testing the behavior of a large set of inputs where system behavior differs with each set of inputs, decision table testing provides good coverage and the representation is simple so it is easy to interpret and use.

In Software Engineering, boundary value and equivalent partition are other similar techniques used to ensure better coverage. They are used if the system shows the same behavior for a large set of inputs. However, in a system where for each set of input values the system behavior is different, boundary value and equivalent partitioning technique are not effective in ensuring good test coverage.

In this case, decision table testing is a good option. This technique can make sure of good coverage, and the representation is simple so that it is easy to interpret and use.

This table can be used as the reference for the requirement and for functionality development since it is easy to understand and cover all the combinations.

The significance of this technique becomes immediately clear as the number of inputs increases. Number of possible Combinations is given by 2 ^ n , where n is the number of Inputs. For n = 10, which is very common in the web-based testing, having big input forms, the number of combinations will be 1024. Obviously, you cannot test all but you will choose a rich sub-set of the possible combinations using decision based testing technique.

Advantages of Decision Table Testing

  • When the system behavior is different for different inputs and not the same for a range of inputs, both equivalent partitioning, and boundary value analysis won’t help, but a decision table can be used.
  • The representation is simple so that it can be easily interpreted and is used for development and business as well.
  • This table will help to make effective combinations and can ensure better coverage for testing
  • Any complex business conditions can be easily turned into decision tables
  • In a case we are going for 100% coverage typically when the input combinations are low, this technique can ensure the coverage.

Disadvantages of Decision Table Testing

The main disadvantage is that when the number of inputs increases the table will become more complex

Decision Table Testing Video

Click here if the video is not accessible