Elements of a Test Case

Test programs can contain one or more test cases, and each test case can have a number of elements to it. These elements are coded as specific entry points that the Micro Focus Unit Testing Framework can recognize.

The Micro Focus Unit Testing Framework uses a number of call prototypes to help construct the entry point names. These prototypes are located in the mfunit.cpy copybook, which is available from the cpylib directory of your product installation directory.

Note: If you are unable to use the copybook, due to its use of level-78 items, which are not supported with mainframe dialects, you must specify the following entry point names:
Element Entry point
test setup MFUS_test_case_name
test metadata setup MFUM_test_case_name
test case MFUT_test_case_name
test teardown MFUE_test_case_name

The main elements are:

The test setup
Any pre-requisite conditions that need to be satisfied before the test case is run can be set up in this section. For example, if the test case requires that a data file already exists or is open ready for input, you can code such things in this section. This section is optional.
...
entry MFU-TC-SETUP-PREFIX & "MyTestCase"
*>initial setup code goes here
goback
...
Tip: Use the snippet testup to enter the stub code for a test setup.
The test metadata setup
There are a number of metadata details that you add directly through your source code, such as test description and test timeout; see Using Dynamic Metadata. This section is optional.
...
entry MFU-TC-METADATA-SETUP-PREFIX & "MyTestCase"
*>initial metadata setup code goes here
goback
...
Tip: Use the snippet testdata to enter the stub code for adding test metadata.
The test case
This section contains the actual testing logic and test assertions.
...
entry MFU-TC-PREFIX & "MyTestCase"
*>test case code goes here
goback
...
Tip: Use the snippet testcase to enter the stub code for a test case.
The test teardown
This section enables you to tidy up the environment, such as releasing or closing resources, after the test has been run. This may be critical if you run multiple test cases within a test suite. This section is optional.
...
entry MFU-TC-TEARDOWN-PREFIX & "MyTestCase"
*>clean-up code goes here
goback
...
Tip: Use the snippet testdown to enter the stub code for a test teardown.

Test cases cannot share setups or teardowns; you must code a separate setup or teardown for each test case that requires one.

The sections relating to a test case can appear in your code in any order, but are run in the order shown here.