Writing Tests

To test elements of your procedural COBOL application, you need to code the testing logic in a test case.

A self-contained unit test is a single COBOL program that includes the test case and the data to be tested. Special entry points in your unit test enable you to set up the data and testing environment (the setup), include the testing logic, and then tidy it up again after the test has run (the teardown). These three elements together make up a test fixture.

This section includes a simple test fixture that demonstrates a complete self-contained unit test, which uses the copybook, mfunit.cpy (supplied with your installation of Visual COBOL) to resolve to the correct entry point names that the test runner will recognize. For details of the test fixture syntax, see Elements of a Test Fixture.

If you have related test cases, you can include these in the same COBOL program, each with their own test setup and teardown. COBOL programs that contain more than one test case are referred to as test suites.

You may also write unit tests where the testing logic is completely separate from the data and testing environment (that is, in separate programs). This section also contains an advanced example that demonstrates this technique.