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 COBOL 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 properties of the aircode.cbl resource in the test project.
    1. In COBOL Explorer view, expand TestAirportDemo to display the aircode.cbl resource.
    2. Right-click aircode.cbl and select Properties.

      The properties for aircode.cbl are displayed.

    3. Select COBOL in the left-hand pane.
    4. On the COBOL page, check Enable configuration specific settings, then set Enable code coverage to true.
    5. Click Apply and Close.

      Code coverage is enabled for the aircode.cbl resource.

  3. Then, you need to enable code coverage in the run configuration that will be launched when the tests are run.
    1. In COBOL 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.

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

    The test case runs and produces some code coverage statistics.

  5. 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.

  6. Expand AirportDemo > aircode to show the sections.

    This shows the amount of source code that was executed during the last test run.

This concludes the tutorial.