Running an Application with Code Coverage

Note: This facility is supported in native COBOL only.

Having enabled code coverage for a project (see Enabling Code Coverage), you need to execute the application in code coverage mode in order to generate the coverage data. There is a different approach to this depending on whether or now the application requires an enterprise server to run.

If your application does not require an enterprise server, to run it in code coverage mode:

  1. In COBOL Explorer, right-click your project and click Run As > Run Configurations.
  2. Create a new COBOL Application configuration, or select an existing one.
  3. In the right side of the dialog box, click the Dynamic Analysis tab.
  4. Check Enable code coverage.
  5. If you want to combine the results of multiple runs of the application with test coverage, check Accumulate data from successive runs,
  6. If necessary, specify names for the directories in your project that will contain the log files and the results files that are different than the default ones - Coverage and CoverageResults.
  7. Click Apply and then click Run to execute your application.
  8. Stop your application.

    After the execution stops, the IDE automatically opens the Code Coverage view that shows the statistics about what percentage of the code has executed. The code in the editor is colorized to indicate covered and missed blocks.

    Running the application with code coverage also produces a binary results file, filename.tcz in the Results directory specified on the launch configuration.

    If Generate reports upon run completion is checked in the IDE preferences for code coverage, Visual COBOL also produces an HTML report. If no preferences are specified for the HTML report, you also receive a Code Coverage Report Generation Options dialog box prompting you to specify how this report should be configured.

If your application requires an enterprise server, to run it in code coverage mode:

  1. In the IDE, ensure code coverage is enabled in your project's properties.
  2. Ensure that the enterprise server is configured to run in Code Coverage mode.

    See Enabling Code Coverage.

  3. Start the server from Server Explorer.

    You might be promoted to specify directories for the generated coverage files. Click OK to confirm your preferences.

  4. Execute your application in the usual manner.
  5. Stop the server in Server Explorer.

    You must stop the server for the IDE to produce the code coverage information. After the execution stops, the IDE automatically opens the Code Coverage view that shows the statistics about what percentage of the code has executed. The code in the editor is colorized to indicate covered and missed blocks.

    Running the application with code coverage also produces a binary results file, filename.tcz in the Results directory specified on the launch configuration.

    If Generate reports upon run completion is checked in the IDE preferences for code coverage, Visual COBOL also produces an HTML report. You might receive a Code Coverage Report Generation Options dialog box for you to specify how this HTML report should be configured.

See Viewing the Code Coverage information.