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.
-
While in the COBOL perspective, select the unit test project in the COBOL Explorer pane.
-
Click
.
The
New COBOL Unit Test dialog box appears.
-
In the
Containing project field, ensure it states the name of your unit test project.
-
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.
-
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):
-
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.