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. First, you need to enable code coverage for the project under test:
    1. In COBOL Explorer, select AirportDemo, then on the Project menu, click Properties.

      The Properties for AirportDemo dialog box appears.

    2. Click Micro Focus > Build Configurations > COBOL.
    3. On the COBOL page, expand the Override project COBOL settings section, check Enable configuration specific settings, then check Enable code coverage.

      GUID-27750072-50E3-4AE9-9122-9F48BC59522E-low.png

    4. Click OK.

      Code coverage is enabled for the AirportDemo project.

  2. Next, you need to enable code coverage in the run configuration that will be launched when the tests are run.
    1. In COBOL Explorer, right-click TestAirportDemo, point to Run As and select Run Configurations.

      The Run Configurations dialog box appears.

    2. In the left-hand pane, select the TestAirportDemo run configuration.

      The details for the run configuration appear in the right-hand pane.

    3. Select the Dynamic Analysis tab.
    4. Check Enable code coverage, click Apply, then click Close.

      GUID-78831425-F75D-4458-A4A6-3F5971168A02-low.png

      Code coverage is enabled for the run configuration used to run the tests.

  3. In the Micro Focus Unit Testing view, click GUID-EBBAE910-5DB3-494B-BD0E-C2F479A60A6C-low.png (Run All).

    The test case runs and produces some code coverage statistics.

  4. Select the Code Coverage tab.

    The code coverage details are displayed in the Code Coverage view, grouped under each program name in the AirportDemo project.

  5. Expand AirportDemo > aircode to show the sections.

    GUID-AA3E214B-53B4-4BA7-86D3-3DDDE9CE3F4E-low.png

    As you can see, the test run did not cover much of the source code. Take note of the distance-between-airports section, as we will enhance the test to run this section, and will see different results after the next test run.