Previous Topic Next topic Print topic


Elements of a Test Fixture

The three elements of a complete test fixture are coded as entry points in a COBOL program. The entry points shown here are using call prototypes found in the mfunit.cpy copybook, available from the cpylib folder of your product installation directory. If you are unable to use the copybook due to its 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 MFUT_
test teardown MFUE_

The three 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
...
The test case
This section contains the actual testing logic and test assertions.
...
entry MFU-TC-PREFIX & "MyTestCase"
//test case code goes here//
goback
...
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
...

If you have multiple test cases, each must have their own setup and teardown. COBOL programs that contain more than one test fixture are commonly referred to as test suites.

These sections can appear in your code in any order, but are run in the order shown here.

Previous Topic Next topic Print topic