Creating a Test Fixture

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

  1. In COBOL Explorer, ensure that the TestAirportDemo project is selected, then select File > New > COBOL Unit Test.

    The New COBOL Unit Test dialog box is displayed.

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

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

    GUID-99F9DAE6-3B3C-424A-81E9-D772D8A047AC-low.png

  6. 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 > COBOL.
    3. Ensure that Platform Target is set to 32 bit, then click OK.
  7. 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.

      GUID-88A262F5-AE4F-40CF-910F-E526AD3A4793-low.png

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

      GUID-F31E58F4-290C-4AE3-8E43-D4D0368B6FF1-low.png

    • 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).

      GUID-DB90E2DB-DE97-4E01-B29B-0C4758024C17-low.png

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

      GUID-509BB75F-B848-4532-BB94-9B2FBFF4EA17-low.png

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

      GUID-14CC1470-4DB5-4333-870A-FBD1CA2B6DCA-low.png