Creating Tests

The Unit Test Library project type is designed to house your test cases. When creating a project of this type, you can create a standalone project or you can create one in a solution that already contains the application logic that you want to test.

Standalone projects require you to add the source code that is under test directly to the test case. The real power of the Micro Focus Unit Testing Framework is when you create the unit test library project within a solution that already contains the source code you want to test.

In the latter scenario, your test cases can call into other projects within the solution as long as they are link library projects; this is why we recommend that you separate out your user interface code and logic code into separate projects, where possible.

Test cases are contained within a test program (a .cbl file within the unit test library). When you create a test program from your existing application logic, a number of elements are added to the test program, to enable you to call directly into the existing logic.

Once this infrastructure is in place, you can start to code your test cases, which can include a setup section (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 section (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.