Creating Tests

The COBOL Unit Test Project is the project type that you can use to perform unit testing on native COBOL programs.

Within these projects, you create test fixtures (type COBOL Unit Test), and within the fixture files, you create the test cases.

Within each test case, you can directly add the code that is under test, thus creating a standalone unit test project. However, the real power of the Micro Focus Unit Testing Framework is when your unit test project calls into another project within the workspace, and tests the code directly at source.

In order to call directly into another project, you must ensure that your unit testing project specifies the project under test in its build path (Properties > Micro Focus > Build Path > Projects); then, using procedure pointers, the test cases can access the source code directly. There are other pre-requisites for linking the two projects, which are discussed in Organizing your Workspace.

When you create a test fixture file, you can use the Create unit test from program option, which will add the necessary configuration required to start coding test cases that call directly into the source code.

Test cases have a number of elements to them, which include a setup phase (to ensure that the test environment is correct), the test itself (which calls into the source code, and makes assertions based on success or failure), and a teardown phase (to tidy up after the test run to ensure no negative effects for subsequent tests).

There is also a fourth section that enables you to code any metadata associated with the test cases. Most metadata is optional, but some tests (data-driven tests) require that you use metadata to set the source of your data. See Using Dynamic Metadata for more information.