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

    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