Previous Topic Next topic Print topic


Code Coverage (Native COBOL)

Code coverage for native COBOL in Visual COBOL integrates the Micro Focus Test Coverage facility.
Note: This facility is supported in native COBOL only.

Code coverage enables the development teams to show that they have performed testing which has covered all logical paths through a program, produce a report to illustrate the extent of test coverage, and then promote this report along with the source code at the various stages of the development lifecycle.

These are the steps to enable code coverage for your applications and then run them to produce code coverage reports:

  1. Enable code coverage in the properties of a project, a build configuration's or a file.
  2. Compile your project to apply the changes.
  3. Create a launch configuration that has code coverage enabled and execute your application in it.

While an application is running with code coverage, code execution is logged for each program and sub-program that has been compiled with code coverage enabled. 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 with code coverage uses significantly more resources than running the same program without code coverage enabled. As a result, we recommend that you use code coverage only in development systems; we recommend that you do not use code coverage in production systems.

The results file, .tcz, is a binary file. For convenience, code coverage can also produce a formatted HTML report.

You can also tag statements in your source code and use code 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.

Restrictions

As code coverage integrates the Test Coverage utility, the following restrictions apply:

  • Test coverage does not support nested programs. In particular, it does not work for programs which call the cobsetjmp() and coblongjmp() APIs that are used when calling nested programs.
  • Manually changing the execution point while debugging a program produces test coverage results that are unpredictable.
  • If you have a multi-threaded program (one that is compiled with the REENTRANT directive) and you compile it with the test coverage enabled and run it under test coverage, the test coverage results obtained will be unpredictable.
  • When you use test coverage with preprocessors, only the basic blocks of the original code are taken into account.
Previous Topic Next topic Print topic