Creating a test case template

Use the z/OS® Automated Unit Testing Framework (ZUnit) test case wizards to create test case templates for Enterprise COBOL and Enterprise PL/I applications.

About this task

A test case is a COBOL or PL/I program that is generated by the ZUnit framework for testing another COBOL or PL/I program. The following diagram illustrates the structure of a test case program:
A test case program includes the following programs or procedures. Click the link to see an example of each program in COBOL and in PL/I:
TESTCASE (COBOL PL/I)
The primary entry point from the perspective of the ZUnit test runner. This entry point is expected to call the AZUTCINI API to register the test case with the test runner and provide the locations of the ADDTESTS, SETUP, and TEARDOWN entry points.

In generated COBOL test cases, this entry point is the first program in the test case source file whose name matches the test case source file name.

In generated PL/I test cases, this entry point is the only procedure declared with options(fetchable) whose name matches the test case source file name.

ADDTESTS (COBOL PL/I)
This entry point, whose location is provided to the ZUnit test runner on the call to the AZUTCINI API in TESTCASE, contains calls to the AZUTCADD API to add subprograms (COBOL) or procedures (PL/I) within the current test case to the list of tests that the test runner runs. The number of tests that can be added is limited to available memory. Attempting to add tests outside of the scope of ADDTESTS, for example when the test runner calls a test subprogram or procedure, is not allowed. It is, however, legal to call another program from within the scope of ADDTESTS that in turn calls the AZUTCADD API.
SETUP (COBOL PL/I)
This entry point, whose location is provided to the ZUnit test runner on the call to the AZUTCINI API in TESTCASE, is called by the ZUnit test runner before it calls each test entry point to allow for creation of a test fixture that is relevant to the current test. If a test fixture cannot be created for the current test for any reason, the AZUASTFA or AZUASTFM assertion APIs can be called to fail the current test.
TEARDOWN (COBOL PL/I)
This entry point, whose location is provided to the ZUnit test runner on the call to the AZUTCINI API in TESTCASE, is called by the ZUnit test runner after it calls each test entry point to allow for freeing the test fixture that is allocated for the current test in a previous call to the SETUP entry point. If a test fixture cannot be freed for any reason, the AZUASTFA or AZUASTFM assertion APIs can be called to fail the current test.
TEST001. . . TESTnnn (COBOL PL/I)
These entry points, whose locations are provided to the ZUnit test runner on calls to the AZUTCADD API in the ADDTESTS entry point, are started by the ZUnit test runner so that a test fixture, created in an immediately preceding call to the SETUP entry point, can be used to verify the correctness of a program under test. When the program or programs under test exhibit unexpected behavior or output, the AZUASTFA and AZUASTFM APIs can be called to fail the current test.
In COBOL test cases, ADDTESTS, SETUP, TEARDOWN, and TEST001. . . TESTnnn are subprograms (non-nested and therefore compatible with FUNCTION-POINTER). In PL/I test cases, they are internal procedures that are declared at the package level (non-nested).