Create a Native Test Fixture

Use this process to create a test fixture file within a unit test project, for unit testing native COBOL code. You can directly populate it with your test code, or link it to existing code in your workspace that you plan to test.
  1. While in the COBOL perspective, select the unit test project in the COBOL Explorer pane.
  2. Click File > New > COBOL Unit Test.

    The New COBOL Unit Test dialog box appears.

  3. In the Containing project field, ensure it states the name of your unit test project.
  4. In the New file name filed, type the name of your test fixture program.
    Restriction: Do not use the file name mfunit, as this will not run within the Micro Focus Unit Testing Framework.
  5. At this point, you can create a test fixture that links into an existing COBOL program, or create a standalone test fixture (in which you will add the code under test directly to the test cases):
    • To create a linked fixture file, select Create unit test for program, then click Browse, select the program that contains the code you want to test, then click OK.
      Note: The selected program must be from a local project that is built to a single native library file or all int/gnt files, and must share the same Platform Target setting as your test project.
    • To create a standalone fixture file, select Create Unit Test from Template, then select Micro Focus template.

      You may have also configured your own templates; in which case, choose an appropriate template.

  6. If you have selected Create unit test from program, you can click Next to review and select the entry points in the program for which you want to create test cases.
  7. Enable the check boxes for the entry points for which you want to create test cases.
  8. Click Finish.

    The test fixture file is created within the unit test project.

Both types of fixture file contain similar stub code. Some of the essential elements and additional configuration (required for linked fixture files) are as follows:
Note: The following excerpts were a result of selecting a program from the AirportDemo project.
  • The two copybooks required by the Micro Focus Unit Testing Framework are copied into the project.

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