Creating a Test Fixture

You now need to add a test fixture file to the unit test project.

  1. In COBOL Explorer view, ensure that the TestAirportDemo project is selected, then click File > New > Other.

    This opens the New dialog box.

  2. Expand Micro Focus COBOL, and then click COBOL Unit Test.
  3. Click Next.

    This opens the New COBOL Unit Test dialog box.

  4. In the Containing project field, ensure that it states the TestAirportDemo project.
  5. In the New file name field, type DistanceTest.
  6. Select Create unit test from program, click Browse, select the aircode.cbl program (from within the AirportDemo project), then click OK.
  7. Click Finish.

    The DistanceTest.cbl test fixture file is created within the TestAirportDemo unit test project.

  8. Before you can run the unit test project, you need to ensure that it shares the same platform target value as the project under test. In this case, the AirportDemo project is 32 bit, and so the TestAirportDemo project also needs to be set to 32 bit:
    1. Right-click TestAirportDemo and select Properties.
    2. Select Micro Focus > Build Configurations > Link.
    3. Ensure that Bitism is set to 32 bit, then click Apply and Close.
  9. Review the following items that have been added to the resulting fixture file. They are all required to allow you to call into the AirportDemo project:
    • The two copybooks required by the Micro Focus Unit Testing Framework are copied into the project.

      Unit testing copy files

    • A test setup and a test case have been created.

    • A procedure pointer has been added to the test setup that enables you to call into the source code, and a level 78 constant for the test case name has been added (to help when creating the different elements of the test case).

    • The Linkage section from the source program has been replicated in the Working-storage section, initialized, and a CALL statement coded in the test case.

    • The project containing the program under test is added to the Projects tab of the Build Path properties.

      Project properties build path