Segment 6 (Part 2)
Segment 6 (Part 2)
A graph matrix is a data structure that can assist in developing a software tool for
automation of basis path testing. A graph matrix is a square matrix whose size (i.e.,
number of rows and columns) is equal to the number of nodes on the flow graph. Each
row and column corresponds to an identical node, and matrix entries corresponds to
connections (an edge) between nodes. Conventionally, nodes are denoted by digits and
edges are denoted by letters.
Let’s convert this control flow graph into a graph matrix. Since the graph has 4 nodes, so
the graph matrix would have a dimension of 4 X 4. Matrix entries will be filled as
follows:
(1, 1) will be filled with ‘a’ as an edge exists from node 1 to node 1
(1, 2) will be filled with ‘b’ as an edge exists from node 1 to node 2. It is
important to note that (2, 1) will not be filled as the edge is unidirectional and
not bidirectional
(1, 3) will be filled with ‘c’ as edge c exists from node 1 to node 3
(2, 4) will be filled with ‘d’ as edge exists from node 2 to node 4
(3, 4) will be filled with ‘e’ as an edge exists from node 3 to node 4
The graph matrix formed is shown below :
Connection Matrix
A connection matrix is a matrix defined with edges weight. In simple form, when a
connection exists between two nodes of control flow graph, then the edge weight is 1,
otherwise, it is 0. However, 0 is not usually entered in the matrix cells to reduce the
complexity.
For example, if we represent the above control flow graph as a connection matrix, then
the result would be:
As we can see, the weight of the edges are simply replaced by 1 and the cells which were
empty before are left as it is, i.e., representing 0.
A connection matrix is used to find the cyclomatic complexity of the control graph.
Although there are three other methods to find the cyclomatic complexity but this
method works well too.
1. Count the number of 1s in each row and write it in the end of the row
2. Subtract 1 from this count for each row (Ignore the row if its count is 0)
3. Add the count of each row calculated previously
4. Add 1 to this total count
5. The final sum in Step 4 is the cyclomatic complexity of the control flow graph
Let’s apply these steps to the graph above to compute the cyclomatic complexity.
We can verify this value for cyclomatic complexity using other methods also.
Equivalence partitioning and Boundary value Analysis
We need an easy way or special techniques that can select test cases intelligently
from the pool of test-case, such that all test scenarios are covered.
We use two techniques - Equivalence Partitioning & Boundary Value Analysis
testing techniques to achieve this.
Equivalence Partitioning
Example:
Any Number greater than 10 entered in the Order Pizza field (let say 11) is
considered invalid.
Any Number less than 1 that is 0 or below, then it is considered invalid.
Numbers 1 to 10 are considered valid.
Any 3 Digit Number say -100 is invalid.
We cannot test all the possible values because if done, the number of test cases will be
more than 100. To address this problem, we use equivalence partitioning hypothesis
where we divide the possible values of tickets into groups or sets as shown below
where the system behaviour can be considered the same.
The divided sets are called Equivalence Partitions or Equivalence Classes. Then we pick
only one value from each partition for testing. The hypothesis behind this technique
is that if one condition/value in a partition passes all others will also pass.
Likewise, if one condition in a partition fails, all other conditions in that partition
will fail.
Boundary value Analysis
In our earlier equivalence partitioning example, instead of checking one value for each
partition, you will check the values at the partitions like 0, 1, 10, 11 and so on. As you
may observe, you test values at both valid and invalid boundaries. Boundary Value
Analysis is also called range checking.
Equivalence partitioning and boundary value analysis (BVA) are closely related and can
be used together at all levels of testing.
This testing is used to reduce a very large number of test cases to manageable
chunks.
Very clear guidelines on determining test cases without compromising on the
effectiveness of testing.
Appropriate for calculation-intensive applications with a large number of
variables/inputs.
Both are used when practically it is impossible to test a large pool of test cases
individually.
In Equivalence Partitioning, first, you divide a set of test condition into a
partition that can be considered.
In Boundary Value Analysis you then test boundaries between equivalence
partitions.