Use this process to create a self-contained test, which is a copybook that is inserted into the source program of a native
COBOL or mainframe project when run under the
Micro Focus Unit Testing Framework.
You should have already created a unit test project in which to store this unit test. Due to the strict naming conventions
for the copybook containing this type of test, create each self-contained test in its own unit test project. However, you
can create multiple projects that test the same source program.
-
While in the COBOL perspective, select the unit test project in the
COBOL Explorer pane.
-
Right-click the project, point to
New, and select
COBOL Unit Test.
The
New COBOL Unit Test dialog box appears.
-
Select
Self Contained Unit Test, and then click
Next.
-
In the
Containing project field, ensure it states the name of your unit test project.
-
Click
Browse to the right of the
Program under test field, select the program that contains the code you want to test, then click
OK.
-
Click
Finish.
Note: If a self-contained test already exists for that program, you are prompted to overwrite it: click
Yes to replace the existing copybook, or click
No to select another program to put under test.
In the unit test project:
- A copybook is created that when run through the
Micro Focus Unit Testing Framework will be inserted into the source code for the duration of the test run; this is where you add your test code. The name of
the copybook is important: it must consist of the program-id of the source program, prefixed
MFUPD_, in order that both the source and the test run as a single unit of work during the test run. To create further test cases,
add further entry points (prefixed
MFUT_) to the copybook.
Tip: Create an additional copybook,
MFUWS_<prog-name>.cpy, to include additional working storage items that your test case requires for the test run.
<prog-name> must be the same name as used for the
MFUPD_ copybook.
- A link to the program under test is added.
- Within the properties of the linked file resource, the MFUPP preprocessor has been enabled.
- A number of other project properties and copypaths are also copied over from the project under test in order for all files
to run as a single unit of work during the test run.