Last modified: May 28, 2014
In this lab, we will look at white-box testing of a program that you should all be quite familiar with.
Review the program from the earlier “Working with ADTs” assignment in light of what you have learned this week about white-box testing.
Log into your account on one of our Linux servers. Create a convenient working directory, cd into it. Copy into that directory your code from that earlier assignment.
If you did poorly in that assignment, you can return to the assignment’s submission page and get our solution. But if you got even partial credit for correct operation on that assignment, it may be more interesting to stick with your own code and see whether white-box testing might have helped.
Add to your working directory this makefile.
Be careful – some web browsers will try to rename that file to “makefile.” or “makefile.txt” when you download it. The name should simply be “makefile”. If your browser gives you something else, use the Linux mv command to rename the file,
Delete any executable or object code (.o) files in the directory. (You can do this via the usual Linux rm command or by issuing the command make clean).
Compile the program by giving the command make.
Note that the g++ compilation commands being issued include the special command flags for tracking white-box coverage.
The makefile should generate an executable program named mainProgram.
Execute the compiled program on any test data that you used for the assignment.
Generate the statement coverage report by giving the command
make report1
Look at the directory. You should see several *.gcov files. Some of these correspond to the .h and .cpp files of your program. Some may correspond to files from the C++ std:: library.
Examine the *.gcov files corresponding to the .cpp files of your code using an editor or the more or less commands.
Were any statements missed by your tests?
Get the instructors’ test data distributed with the assignment solution and run it through the program. Re-generate the statement coverage report and examine the *.gcov files again. Did the coverage improve?
Reset the coverage statistics by giving the command
make reset
Execute the compiled program on any test data that you used for the assignment.
Generate the branch coverage report by giving the command
make report2
Examine the *.gcov files corresponding to the .cpp files of your code using an editor or the more or less commands.
Were any branches missed by your tests?
Get the instructors’ test data distributed with the assignment solution and run it through the program. Re-generate the branch coverage report and examine the *.gcov files again. Did the coverage improve?