Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Using Code Coverage with Visual COBOL

Using Code Coverage with Visual COBOL

Problem:

I need to show that I have tested all logical paths through a program.

Resolution:

Note: This facility is supported in native COBOL only.


Code Coverage

Visual COBOL provides support for code coverage of native COBOL applications directly from within the IDE. In order to produce reports, code coverage needs to be enabled within a project's properties, programs need to be compiled and run with code coverage to produce the relevant reports.

Follow these instructions to enable code coverage and produce code coverage reports:

  • Enable Code Coverage on the COBOL page in the properties of the project.

  • Rebuild the project to apply the changesThe application can now be run in code coverage mode by selecting Debug > Start With Micro Focus Code Coverage.

Running the application with code coverage will produce a Results.tcz file in the folder specified in Tools > Options > Micro Focus > Code Coverage > Results Options. This file provides statistics in the Micro Focus Code Coverage window and includes information about the percentage of the code that has been executed, as well using color to indicate areas of the code in the editor that have been executed or not executed. Code execution is logged for each program and sub-program. In addition HTML reports can be created from within the Micro Focus Code Coverage window. If the window is not visible, to display it click View > Micro Focus Code Coverage.

 

Double-clicking on a line within Code Coverage window will place the cursor on the relevant code within the Editor window.

The color preferences for the colorization of covered and missed blocks can be changed in Tools > Options > Environment > Fonts and Color:


The history of running the application with code coverage is saved in a History subfolder in the location of the Results.tcz file. The results from previous runs with code coverage can be loaded into the Micro Focus Code Coverage window (see below).


Micro Focus Code Coverage Window Toolbar


 Export code coverage information and save it as a .tcz results file.

 Import code coverage information from an existing .tcz results file.

 Merge results files from different executions with code coverage, this will create a MergedCoverageFile_datetime.tcz.

 Toggle the code coverage colorization on or off in the editor.

 Delete the Results_datetime.tcz that is currently loaded, this will unload the file from the IDE and deletes it from disk.

 Generate the code coverage HTML format reports. This creates the index report file, TCIndex.htm, and any of the reports in HTML format.

 

The IDE preferences determine whether to produce a single HTML report file or multiple reports (individual .HTM files produced for each program):


Single report file:


Click on of the tcreport.htm link to view the report.

Multiple report files:


Click on the links to view the individual reports.

Example report file:


The report includes a summary of the percentage of statements, Call statements, blocks etc. that have been executed in the program:


For further information, please refer to the product documentation.

 


 

 



DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2016-12-16 17:46
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.