Appendix D

Test Coverage Data in Diagrams

In this appendix, an example is used for illustrating the test coverage analysis metrics of Panorama C/C++.

SUM_PRODUCT is a sample program which requests the input of three integers: Low, High and Max. The integers should not be negative, otherwise an error message will be given. When SUM_PRODUCT receives three integers, it outputs for each number k in the

The source code of SUM_PRODUCT.cc is listed below:

sum_pro.GIF - 6.39 K

The Makefile of SUM_PRODUCT is listed below:

sum_mak.GIF - 1.54 K

A SUM_PRODUCT.hsi file is generated from the Makefile of SUM_PRODUCT and loaded into the Main Menu of Panorama C/C++. Then, a .dbs file is created for SUM_PRODUCT. To capture the dynamic test coverage data, SUM_PRODUCT is executed with several groups of integers as listed below:

LOW HIGH MAX
2
8
0
10
20
12
10
1
11
2
8
-2
2
-2
8
-2
2
8

A series of bar graphs in OO-Test, J-Flow and J-Diagrams in OO-Diagrammer are listed to show the changes of accumulated test coverage each time when SUM_PRODUCT is executed.

Note: In this Appendix, the test coverage refers to the Accumulated test coverage in order to show the result of all the executions.

Before the execution of SUM_PRODUCT, the test coverage of the code is zero. This is reflected in the bar graph and diagrams below:

Snap11.gif - 4.79 K

Figure A-1. Bar graph in OO-Test:

The test coverage data are all zero.

Snap12.gif - 4.47 K

Figure A-2. Bar graph in OO-Test:

The untested element list

snap13.GIF - 5.45 K

Figure A-3. J-Flow in OO-Diagrammer:

All the elements are untested and highlighted.

snap14.GIF - 10.56 K

Figure A-4. J-Diagram in OO-Diagrammer:

Accumulated test coverage: All the elements are untested and highlighted.

To execute the sample program, type SUM_PRODUCT under appropriate directory at prompt:

ipc004{zkm}/home3/zkm/panorama/jay 150 >SUM_PRODUCT

Enter positive integers LOW, HIGH, and MAX: 2 8 0

LOW = 2 HIGH = 8 MAX =0

The bold characters above are typed in at the prompts, while the italic characters are displayed by the sample program SUM_PRODUCT.

Then check the Bar graphs in OO-Test, J-Flow and J-Diagram in OO-Diagrammer. Select the Accumulated test coverage on the corresponding Options dialog box, then click OK. The test coverage data are automatically updated:

Snap21.gif - 5.39 K

Figure A-5. Bar graph in OO-Test

The test coverage data show, after the first execution of SUM_PRODUCT, that the test coverage of Function and Condition True have been 100 percent.

Snap22.gif - 4.46 K

Figure A-6. Bar graph in OO-Test

The untested elements list shows that all the Functions and True conditions have been tested.

snap23.GIF - 5.51 K

Figure A-7. J-Flow in OO-Diagrammer:

After the first execution of SUM_PRODUCT.

snap24.GIF - 10.31 K

Figure A-8. J-Diagram in OO-Diagrammer:

After the first execution of SUM_PRODUCT.

Now, execute SUM_PRODUCT again. This time three integers 10, 20, and 12 are inputted. SUM_PRODUCT outputs, from 10 to 20, 11 groups of equations:

ipc004{zkm}/home3/zkm/panorama/jay 151 >SUM_PRODUCT

Enter positive integers LOW, HIGH, and MAX:10 20 12

LOW = 10 HIGH = 20 MAX =12

10 + 10 = 20 10 * 10 = 100

11 + 11 = 22 11 * 11 = 121

12 + 12 = 24 12 * 12 = 144

13 + 13 = 26 13 * 13 = 169

14 + 14 = 28 14 * 14 = 196

15 + 15 = 30 15 * 15 = 225

16 + 16 = 32 16 * 16 = 256

17 + 17 = 34 17 * 17 = 289

18 + 18 = 36 18 * 18 = 324

19 + 19 = 38 19 * 19 = 361

20 + 20 = 40 20 * 20 = 400

The bold characters above are typed in at the prompts, while the italic characters are displayed by the sample program SUM_PRODUCT.

Then check the Bar graphs in OO-Test, J-Flow and J-Diagram in OO-Diagrammer. Select the Accumulated Test Coverage Data on the corresponding Options dialog box, then click OK. The test coverage data on the diagrams are automatically updated:

Snap31.gif - 5.44 K

Figure A-9. Bar graph in OO-Test:

Accumulated test coverage:

Function and Condition True remains 100% covered. Other test metrics data have increased significantly.

Snap32.gif - 4.41 K

Figure A-10. Bar graph in OO-Test:

Accumulated test coverage: the numbers of untested elements have decreased after hte second execution of SUM_PRODUCT.

snap33.GIF - 5.57 K

Figure A-11. J-Flow in OO-Diagrammer:

accumulated test coverage after the second execution

snap34.GIF - 11.15 K

Figure A-12. J-Diagram in OO-Diagrammer:

Accumulated Test Coverage: The number of unexecuted elements highlighted has been greatly decresed compared to the diagrams before.

Now, execute SUM_PRODUCT again to increase its test coverage furthermore. This time integers 10, 1, 11 are inputted.

ipc004{zkm}/home3/zkm/panorama/jay 152 >SUM_PRODUCT

Enter positive integers LOW, HIGH, and MAX:10 1 11

LOW = 10 HIGH = 1 MAX =11

The bold characters above are typed in at the prompts, while the italic characters are displayed by the sample program SUM_PRODUCT.

Since Low=10 > High=1, no equation is outputted this time.

Then check the Bar graphs in OO-Test, J-Flow and J-Diagram in OO-Diagrammer. Select the Accumulated Test Coverage on the corresponding Options dialog box, then click OK. The test coverage data are automatically updated:

Snap41.gif - 5.46 K

Figure A-13. Bar graph in OO-Test:

Accumulated Test Coverage: Compared to Figure A-9, one more branch and one more segment are tested. Consequently, J-Coverage is increased by one too.

Snap42.gif - 4.31 K

Figure A-14. Bar graph in OO-Test:

Accumulated Test Coverage: The number of untested elements is further decreased.

snap43.GIF - 5.59 K

Figure A-15. J-Flow in OO-Diagrammer:

Accumulated test coverage: Compared to Figure A-11, one more segment (branch) is tested.

snap44.GIF - 10.12 K

Figure A-16. J-Diagram in OO-Diagrammer:

Accumulated Test Coverage: Compared to Figure A-12, one more segment (branch) is tested.

Now, carefully observe the J-Flow or J-Diagram, you may find out that the condition test coverage should be increased. Since Condition True has reached 100% coverage, the Condition False needs to be increased.

ipc004{zkm}/home3/zkm/panorama/jay 153 >SUM_PRODUCT

Enter positive integers LOW, HIGH, and MAX:2 8 -2

LOW = 2 HIGH = 8 MAX =-2

Error! The input data are incorrect!

The bold characters above are typed in at the prompts, while the italic characters are displayed by the sample program SUM_PRODUCT.

Since a negative integer is inputted, an error message is given this time.

Then check the Bar graphs in OO-Test, J-Flow and J-Diagram in OO-Diagrammer. Select the Accumulated test coverage on the corresponding Options dialog box, then click OK. The test coverage data are automatically updated:

Snap51.gif - 5.33 K

Figure A-17. Bar graph in OO-Test:

The accumulated test coverage data of Branch, SC0, SC1 and SC1+ have reached 100%. The Condition False, Condition Both and J-Coverage have been increased too.

Snap52.gif - 4.13 K

Figure A-18. Bar graph in OO-Test:

Accumulatively, only 2 elements in Condition False or in Condition Both or in J-Coverage are untested.

snap53.GIF - 5.60 K

Figure A-19 J-Flow in OO-Diagrammer:

Accumulated test coverage: only 2 conditions are untested.

snap54.GIF - 10.73 K

Figure A-20 J-Diagram in OO-Diagrammer:

Accumulated Test Coverage: only 2 conditions are untested.

To increase the coverage of Condition False, run SUM_PRODUCT again and input another group of integers. This time, integer High is negative.

ipc004{zkm}/home3/zkm/panorama/jay 154 >SUM_PRODUCT

Enter positive integers LOW, HIGH, and MAX:2 -2 8

LOW = 2 HIGH = -2 MAX =8

Error! The input data are incorrect!

The bold characters above are typed in at the prompts, while the italic characters are displayed by the sample program SUM_PRODUCT.

Since negative integer High is inputted, an error message is given too.

Then check the Bar graphs in OO-Test, J-Flow and J-Diagram in OO-Diagrammer. Select the Accumulated test coverage in the corresponding Options dialog box, then click OK. The test coverage data are automatically updated:

Snap61.gif - 5.37 K

Figure A-21. Bar graph in OO-Test:

Accumulated test coverage: only 1 condition is untested.

Snap62.gif - 4.15 K

Figure A-22. Bar graph in OO-Test:

Accumulatively, only 1 condition in Condition False or in Condition Both or in J-Coverage is untested.

snap63.gif - 5.55 K

Figure A-23. J-Flow in OO-Diagrammer:

Accumulated test coverage: only 1 False condition is untested.

snap64.gif - 9.70 K

Figure A-24. J-Diagram in OO-Diagrammer:

Accumulated Test Coverage: only 1 False condition is untested.

To cover all the conditions, run SUM_PRODUCT again and input another group of data with negative Low integer.

ipc004{zkm}/home3/zkm/panorama/jay 155 >SUM_PRODUCT

Enter positive integers LOW, HIGH, and MAX:-2 2 8

LOW = -2 HIGH = 2 MAX =8

Error! The input data are incorrect!

The bold characters above are typed in at the prompts, while the italic characters are displayed by the sample program SUM_PRODUCT.

Since negative integer Low is inputted, an error message is given too.

Then check the Bar graphs in OO-Test, J-Flow and J-Diagram in OO-Diagrammer. Select the Accumulated test coverage on the corresponding Options dialog box, then click OK. All the conditions should have been covered:

Snap71.gif - 5.26 K

Figure A-25. Bar graph in OO-Test:

Accumulated test coverage: all the test coverage metrics have reached 100%.

The sample program SUM_PRODUCT is completly tested.

Snap72.gif - 3.86 K

Figure A-26. Bar graph in OO-Test:

Accumulatively, no untested element remains.

The sample program SUM_PRODUCT is completly tested.

snap73.gif - 5.57 K

Figure A-27. J-Flow in OO-Diagrammer:

Accumulated test coverage: The program SUM_PRODUCT is completely tested.

snap74.gif - 10.72 K

Figure A-28. J-Diagram in OO-Diagrammer:

Accumulated test coverage: The program SUM_PRODUCT is completely tested.

From the example above, it is clearly shown how test coverage data are displayed on J-Flows and J-Diagrams, and how the result shown may help you to increase the coverage of your program.

Similarly, other tools of Panorama C/C++, such as the structure charts, software metrics diagrams, reports, ActionPlus diagrams, etc., can also show the dynamic test data vividly and help you successfully plan the further testing.


back to Table of Contents