Tuesday, 12 April 2016

DD Path Testing: First Steps

While considering the schematics of the program given to us, we decided to include structural testing among our testing techniques. Structural testing is well suited for unit testing and within our program, we have decided to assume that all 'locations' inputted by the user should be units, i.e. not decimal numbers.

The task given to me was to cover the testing of the program using the DD Path Testing technique, focusing on path coverage. Path coverage tends to focus a little too much on the graph rather than the logic of the code but we felt it would be useful in determining the quality of our testing.

Creating a Control Flow Graph is an integral part of DD Path Testing so I made sure to spend time working on it. It took several drafts of the graph based on the code in the earlier blog post before I decided on a version that I thought was acceptable. I labelled the true and false paths within the diagram below and I provided a key* below of the statements which require explanation.

Control Flow Graph for the program


Key to assist above diagram



Node Number
Meaning in program (General)
1
Setting up the program/Statements
2
‘while(steps == 0)’
3
Take in the value
4
Catch exception and prompt user
5
‘while(prev == 0)’
6
Take in value(s)
7
Catch exception and prompt user
8
Setting up program/Statements
9
‘while(i < steps)’
10
Take in value/Statements
11
Catch exception and prompt user
12
‘if(difference > largestDifference)’
13
Set value/Statement if above is true
14
Set value/Statements
15
Print out final value

*It may be helpful to read the code while reading this as it may improve understanding the key.

Once I had finished with the Control Flow Graph, the next step was to create a DD Path Graph to attempt to simply the graph for testing. To do this, I found that drawing up a table was helpful in condensing the graph. Although I was not able to condense it by much, I found it easier to continue this way. The table is below and simply compare with the CFG above to understand the transition.

Table to convert CFG to DD Path Graph

Program Graph Nodes
DD Path Name
1
First
2
A
3
B
4
C
5
D
6
E
7
F
8 - 9
G
10
H
11
I
12
J
13
K
14
L
15
End

From this table, I was able to draw up my DD Path Graph below. Like the CFG, I drew it a few times before I was happy with its presentation. From here, I can begin creating test cases for my path testing criteria.


DD Path Graph