Test Harnesses for Mainframe AppDev Explained

Setting the stage for Continuous Testing and a new era of code change confidence with Test4z

David McNierney
Modern Mainframe
4 min readAug 26, 2024

--

A test harness creates a stable, controlled environment for testing

Mainframe applications are the engines of business so changing them, no matter how small the scope, requires great care and precision.

Having a structured, stable, and controlled environment to test the changed code is critical — this is the function of a test harness.

By managing the complexities of testing — such as setting up environments, providing inputs, and capturing outputs — a test harness “harnesses” the power of automated testing to ensure that the software is reliable, consistent, and ready for production.

However, a test harness is only effective if developers embrace and apply the technology during unit testing. Equipping engineers with the right testing tools — ones similar to their coding tools — is the key to test automation.

Get it wrong, and automation becomes a chore, subject to neglect.
Get it right, and developers embrace test automation and build it into their workflows.

This article explains why the Test4z test harness is the right tool for z/OS application developers.

Test Harness Overview

The glossary definition is “A set of tools, libraries, and infrastructure that automate the testing of software components or systems; typically includes scripts or cases, data, drivers, mocks, and reporting/logging mechanisms.”

Think of it as a collection of software and test data used by developers to unit test software during development. The harness executes the tests using a library and generates reports.

Mainframe applications tend to be large and complex, which makes a harness even more important. Continuing with the jet engine analogy, the aircraft has many subsystems — flight control, navigation, communications, fuel, hydraulics, etc. — so testing changes to the engine in a controlled, isolated environment is an essential first step.

Mainframe apps have a similar level of integration complexity: program-to-program integrations, program-to-database integrations, and program-to-subsystem integrations.

So testing begins in isolation from other systems (one of the 6 Core Principles of Unit Testing) and the harness provides mocks to other systems. Note that test harnesses support other Unit Testing Core Principles beyond isolation: they help keep tests small, they facilitate continuous integration, etc.

Benefits

When the test harness is in place and prerequisite data is prepared (aka data prep) someone should be able to click a button or run one command to execute all your tests and generate reports.

A test harness is an invaluable tool in software development, particularly in environments where reliability and quality are paramount. It helps teams maintain high standards of software quality while reducing the time and effort required for testing.

Developers can spend significant time preparing mocks for unit tests by hand so automated mocks are a huge time saver. Providing them with a test harness demonstrates support for automation and improved productivity.

In addition, test harnesses ensure that tests can be repeated under the same conditions, which is crucial for verifying that code changes do not introduce new bugs (i.e., regression testing). A test harness can also execute a broad array of test cases, including edge cases and scenarios that might be difficult or time-consuming to test manually, ensuring high quality standards (e.g., code coverage).

An API that creates mock objects from application recordings

Test4z Implementation

With its new release, Test4z offers an enhanced API that creates mock objects automatically from application recordings.

The Create Harness COBOL Test API loads recorded data created by previous record/replay processing to be used by mocking during a unit test. The test harness can also instruct the test to use certain files, Db2, CICS, or programs as real instead of using recorded data. The test harness can use a mixture of mocked and real data. See the Technical Documentation for more details.

Bonus — CICS Unit Testing Preview

The new Test4z release also includes a technical preview of CICS Unit Testing capabilities (i.e., API suite). If you’d like to create automated and repeatable unit tests for your CICS applications, our product team can recommend how to implement the new capabilities in your environment.

To learn more about test harnesses or the CICS technical preview, contact your Broadcom Mainframe Business Specialist or register for a personalized Test4z demonstration.

--

--

David McNierney
Modern Mainframe

DevOps @ Broadcom #devops #zowe #zos #IBMz #mainframe #jenkins #cicd #agile #mhealth #github #vscode