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 the Application Explorer view, 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, check Enable configuration specific settings, then set Enable code coverage to true.
    4. Click Apply and Close.

      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 Application Explorer view, 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.

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

  3. In the Micro Focus Unit Testing view, click (Run All).

    The test case runs and produces some code coverage statistics.

  4. Select the Code Coverage view.

    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.

    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.