Running the Test Under Code Coverage

To produce code coverage statistics during the test run, you must first compile the source application (the project that contains the code to be tested) with code coverage enabled.

  1. In the Solution Explorer pane, expand the AirportLinkLibrary project, then double-click Properties.

    GUID-281507BE-F7FA-45E0-B41D-C14066C98494-low.png

    The project properties appear.

  2. Click the COBOL tab.
  3. On the COBOL pane, select Enable code coverage, then press Ctrl+S to save the changes.
  4. In the Solution Explorer pane, right-click the AirportLinkLibrary project, then click Rebuild.

    The project is rebuilt with code coverage enabled.

  5. In the Micro Focus Unit Testing window, click Run All (Code Coverage).

    The TESTAIRCODE test case is re-run and on completion code coverage statistics are displayed in the Micro Focus Code Coverage window.

  6. Expand the nodes as shown below, to show the sections of the source code that were executed during the test run:

    GUID-32D3AE12-ADFB-4891-BC62-EC1DEA695442-low.png

    Notice that the Section: distance-between-airports entry is showing 0% covered.

  7. Double-click the Section: distance-between-airports entry.

    The cursor is positioned in the source code at the distance-between-airports section, and the source code is colorized red, to indicate that it was not executed. Later in the tutorial, we will view this section again when the code has been executed. For more information on Code Coverage, refer to Code Coverage (Native COBOL).