This article explains how to show that testing has been performed and produce a report to illustrate the extent of test coverage.
Problem:
Development teams often need to show that they have performed testing which has covered all logical paths through a program. How is this done?
Resolution:
Using the test coverage utility, they can produce a report to illustrate the extent of test coverage, and can promote this report along with the source code at the various stages of the development lifecycle.
- While a program is running in test coverage mode, code execution is logged for each program and sub-program that has been compiled with the TESTCOVER directive set. The information stored in the results file depends on how you configure test coverage.
- As the results file is a binary file, it has to be formatted to produce a text or HTML report file. You can create a report file using the reporting utility cobtcreport. Reports can be formatted to produce a plain text (.txt) file or an HTML (.htm) file.
- Restrictions: If you have a multi-threaded program (one that is compiled with the REENTRANT directive) and you compile it with the TESTCOVER directive and run it under test coverage, the test coverage results obtained will be unpredictable.
- Test coverage configuration file:
We recommend that a configuration file ( my.tcf) should contain at least the following:
[TESTCOVER]
ECHOLOG NO
RESULT filename.tcz ACCUMULATE
Set the TESTCOVER environment variable before running your application
Example :
TESTCOVER=./my.tcf
export TESTCOVER
An example test coverage configuration file is supplied in $COBDIR/etc/default.tcf.
5/To create reports using cobtcreport
Example :
cobtcreport filename.tcz COMBINE TEXT NOHTML NOECHO
produces a single text file