Inserting Test Code into Source Code

When your source code is compiled with the MFUPP preprocessor, it can be run within the Micro Focus Unit Testing Framework alongside copybooks that contain the unit test code and any accompanying data.

If the source program and the copybooks are stored in the same location, and adhere to the naming conventions stated below, they can be run as one unit of work. The source code must have a program-id, as this name is used to identify the copybooks to use.

File name Description
MFUWS_prog-id.cpy The additional test data items that are not already defined in the source program. These items are inserted into working-storage when the test case is run.

prog-id is the program-id of the source program under test.

MFUPD_prog-id.cpy The test case code (including the setup, teardown, etc...) to be run against the source code. This is inserted as an entry point at the start of the procedure division of the source under test. Code the entry point as you would any other unit test.

prog-id is the program-id of the source program under test.

Note: You can change the MFUWS_ and MFUPD prefixes in the above naming conventions by using the WS-PREFIX and PD-PREFIX directives; see MFUPP Directives.

To run through a couple of test run examples that use these copybooks, see Using MFUPP to Insert Test Code Into a Program.