A self-contained test is a type of unit test that enables you to insert your test code into the program under test when it is running under the Micro Focus Unit Testing Framework (native COBOL and mainframe COBOL sources only).
By doing this you can test on a more granular level than you can with a program test. With the source code and testing code running as a single unit of work, your unit test can run test assertions on any section or paragraph within the source program. This negates the need for the test setup and teardown code often required for program tests.
When you create a self-contained test, a copybook is created that will be inserted into the Procedure Division of the source program only when you put the source under test. There is an additional copybook that you can also create that provides a Working Storage section to accompany your test code; again, this is only inserted during a test run of the source. In order to insert these copybooks into the source, self-contained tests utilize the MFUPP preprocessor.
The copybooks must be named MFUPD_prog-id.cpy (for the test code) and MFUWS_prog-id.cpy (for the working storage), where prog-id references the program-id of the source program.
As well as these two copybooks, a few other configurations occur:
Due to the strict naming conventions mentioned above, create each self-contained test in its own unit test project. However, you can have many of these projects within the same solution, testing the same source program.