## 6 Case Studies
### Case Study #2: Code Coverage and Test-Case Similarity  
Our base case of experimentation is to consider one program unit and test this unit to establish the base case of the proposed approach. Figure 6(a) shows the sample program unit used during this base case of the experiment. Figure 6(b) shows the graph-based representation of the code presented in Figure 6(a). Our experimentation starts with the basic case in which one program is tested with a set of four cases--see Equation (6)--each of which is executing a specific test path presented in Equation (7). These test paths are traced based on the three levels of execution traces defined in this paper. The four test cases are \(T_{1}\), \(T_{2}\), \(T_{3}\), and \(T_{4}\), and the corresponding set of test paths are \(P_{1}\), \(P_{2}\), \(P_{3}\), and \(P_{4}\), respectively. A program execution trace is used for each test case; see Figure 11.  
\[\text{procedure computeStats(List)}\] \[\text{length := ``List}\] \[\text{if length > 0 then}\] \[\text{sum = 0}\] \[\text{every i := 1 to length}\] \[\text{sum += List[i]}\] \[\text{if length2 = 0 then 4 odd length}\] \[\text{med := List[length+1]/2] \[\text{else }\] \[\text{med := image(List[length+2])}\] \[\text{procedure computeStats(List)}\]0 \[\text{procedure computeStats(List)}\]1 \[\text{procedure computeStats(List)}\]2 \[\text{procedure computeStats(List)}\]3 \[\text{procedure computeStats(List)}\]4 \[\text{procedure computeStats(List)}\]5 \[\text{procedure computeStats(List)}\]6 \[\text{procedure computeStats(List)}\]7 \[\text{procedure computeStats(List)}\]8 \[\text{procedure computeStats(List)}\]9 \[\text{length := ``List}\]0 \[\text{length := ``List}\]1 \[\text{length := ``List}\]2 \[\text{length := ``List}\]3 (a) Code of the computeStats function (b) CFG of the computeStats function  
\[\text{length := ``List}\]4  
\[\text{}\text{}\text{}\text{}\text{}\text{}\text{}\text{}\text{}\text{} \text{}\text{}\text{}\text{}\text{}\text{}\text{}  
* \(T_{3}\) executes the case where the list size is more than one and the body of each loop is entered three times. The executed test path \(P_{3}\) does not add much to the statement coverage included in \(T_{2}\) and its test path \(P_{2}\). Thus, the white-box analysis can show that there is a good percentage of redundancy and test-case similarity in terms of statement coverage between the two test cases \(T_{2}\) and \(T_{3}\) and their corresponding test paths \(P_{2}\) and \(P_{3}\), respectively. **Our evaluation hypothesis is to evaluate and determine if any of the execution-trace similarity measures undertaken will allow us to highlight this fact automatically**. Therefore, to some extent, there is an element of relief for the quality engineer, providing them with the confidence to remove or ignore the use of one of these two test cases due to the overlap between their set of covered program statements. * \(T_{4}\) executes the case where the length of the list is more than one, in a situation very similar to the test case presented in \(T_{3}\), except that this new test case adds to the set of covered statements the scenario where the length of the list is even rather than odd, which leads to having two medians instead of one median in the case of an even number of items in the list. Therefore, this test case has a good similarity with the previous test cases \(T_{2}\) and \(T_{3}\), except for having to enter each of the loops four times and, most importantly, covering **node 6** in the abstract graph representation presented in Figure 7b instead of **node 7**, which is covered in the previous two test cases (\(T_{2}\) and \(T_{3}\)). Therefore, the similarities between this test case and the last two are very high, and only one statement was added to the set of statements covered previously. However, this test case might need to be ranked second for its importance behind test cases 1 and 2. In this paper, we have evaluated three types of string similarities: (1) edit-based distance; (2) token-based algorithms; and (3) sequence-based algorithms.