Development teams often need to show that they have performed testing which has covered all logical paths through a program. 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.
This section provides information about using test coverage from the command line. Visual COBOL provides IDE integration of test coverage within Visual Studio or Eclipse - see Code Coverage (Native COBOL) .
Test coverage results can be included as part of the output of any Continuous Integration (CI) testing that the teams are performing.
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 results are stored in a binary results file, which has the filename extension .tcz. The information stored in the results file depends on how you configure test coverage.
Running a program in test coverage mode uses significantly more resources than running the same program without test coverage enabled. As a result, we recommend that you use test coverage only in development systems; we recommend that you do not use test coverage in production systems.
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 from the command line, using the reporting utility TCReport . Reports can be formatted to produce a plain text (.txt) file or an HTML (.htm) file.
You can also tag statements in your source code and use test coverage to report on whether these statements have been executed. This is particularly useful if you want to see the coverage of new or changed lines in your source code.
In a CI environment, it might be better to create the test coverage results in an alternative format which is better suited for the CI system and for the way the development team wants to integrate the results with the CI. Visual COBOL provides a command line utility for test coverage, tcutil, which enables you to convert the binary results file into an XML file. After the results are in XML format, you can use a Third-Party utility such as an XSLT processor to transform the XML file into a format which is suitable for your CI.