What You Will Learn:
Dynamic Testing Techniques – Cause and Effect Graph.
Test case writing forms an integral part of testing, whether it is manual or automation. Every project is exclusive and has a <n> number of test conditions that need to be covered.
We should focus on two points whenever we write test cases. These are:
Mitigating the risk
This paper revolves around the second point which is “Coverage”. To be precise – Requirements Coverage.
Test case writing techniques for dynamic testing
- Equivalence partitioning
- Boundary Value Analysis
- Decision table
- Cause and effect graph technique
- State transition diagram
- Orthogonal array testing(OATS)
- Error guessing.
We have some really good papers 1st, 2nd and 3rd points (Equivalence portioning, BVA and decision tables) here in STH. I am going to discuss point 4 which is Cause and effect graph.
Cause and effect graph is a dynamic test case writing technique. Here causes are the input conditions and effects are the results of those input conditions.
Cause-Effect Graphing is a technique which starts with a set of requirements and determines the minimum possible test cases for maximum test coverage which reduces test execution time and ultimately cost.
The goal is to reduce the total number of test cases still achieving the desired application quality by covering the necessary test cases for maximum coverage.
But at the same time obviously, there are some downsides of using this test case writing technique. It takes time to model all your requirements into this cause-effect graph before writing test cases.
The Cause-Effect graph technique restates the requirements specification in terms of the logical relationship between the input and output conditions. Since it is logical, it is obvious to use Boolean operators like AND, OR and NOT.
Notations we are going to use:
Now let’s try to implement this technique with some example.
1. Draw a cause and effect graph based on a requirement/situation
2. Cause and Effect graph is given, draw a decision table based on it to draw the test case.
Let’s see both of them one by one.
Let’s draw a cause and effect graph based on a situation
The “Print message” is software that read two characters and, depending on their values, messages must be printed.
- The first character must be an “A” or a “B”.
- The second character must be a digit.
- If the first character is an “A” or “B” and the second character is a digit, the file must be updated.
- If the first character is incorrect (not an “A” or “B”), the message X must be printed.
- If the second character is incorrect (not a digit), the message Y must be printed.
The causes for this situation are:
C1 – First character is A
C2 – First character is B
C3 – the Second character is a digit
The effects (results) for this situation are
E1 – Update the file
E2 – Print message “X”
E3 – Print message “Y”
First, draw the causes and effects as shown below:
Key – Always go from effect to cause (left to right). That means, to get effect “E”, what causes should be true.
In this example, let’s start with Effect E1.
Effect E1 is to update the file. The file is updated when
– The first character is “A” and the second character is a digit
– The first character is “B” and the second character is a digit
– The first character can either be “A” or “B” and cannot be both.
Now let’s put these 3 points in symbolic form:
For E1 to be true – following are the causes:
– C1 and C3 should be true
– C2 and C3 should be true
– C1 and C2 cannot be true together. This means C1 and C2 are mutually exclusive.
Now let’s draw this:
So as per the above diagram, for E1 to be true the condition is
(C1 C2) C3
The circle in the middle is just an interpretation of the middle point to make the graph less messy.
There is a third condition where C1 and C2 are mutually exclusive. So the final graph for effect E1 to be true is shown below:
Let's move to Effect E2:
E2 states to print message “X”. Message X will be printed when the First character is neither A nor B.
Which means Effect E2 will hold true when either C1 OR C2 is invalid. So the graph for Effect E2 is shown as (In blue line)
For Effect E3.
E3 states to print message “Y”. Message Y will be printed when Second character is incorrect.
Which means Effect E3 will hold true when C3 is invalid. So the graph for Effect E3 is shown as (In Green line)
This completes the Cause and Effect graph for the above situation.
Now let’s move to draw the Decision table based on the above graph.
Writing Decision table based on Cause and Effect graph
First, write down the Causes and Effects in a single column shown below
Key is the same. Go from bottom to top which means traverse from effect to cause.
Start with Effect E1. For E1 to be true, the condition is (C1 C2) C3.
Here we are representing True as 1 and False as 0
First, put Effect E1 as True in the next column as
Now for E1 to be “1” (true), we have the below two conditions –
C1 AND C3 will be true
C2 AND C3 will be true
For E2 to be True, either C1 or C2 has to be false shown as
For E3 to be true, C3 should be false.
So it’s done. Let’s complete the graph by adding 0 in the blank column and including the test case identifier.
Writing Test cases from the decision table
I am writing a sample test case for test case 1 (TC1) and Test Case 2 (TC2).
In a similar fashion, you can create other test cases.
(A test case contains many other attributes like preconditions, test data, severity, priority, build, version, release, environment etc. I assume all these attributes to be included when you write the test cases in actual situation)
Summarizing the steps once again:
- Draw the circles for Causes and Graphs
- Start from effects and move towards the cause.
- Look for mutually exclusive causes.
This finishes the Cause and Effect graph dynamic test case writing technique. We have seen how to draw the graph and how to draw the decision table based on it. The final step of writing test cases based on decision table is comparatively easy.
About the Author: This is a guest article by Shilpa Chatterjee Roy. She is working in software testing field for the past 8.5 years in various domains.
Feel free to discuss your test case writing methods in comments below.