Using CA Endevor to Version zUnit Artifacts

Vaughn Marshall
Modern Mainframe
Published in
4 min readFeb 16, 2021

Mainframe Unit Testing with zUnit

A best practice for automated testing is to store the tests themselves with the source code, in a version control system. This enables you to easily retrieve the tests that go with the version of code you are testing at any point in time to run the tests. This particularly true when you are talking about unit tests.

In the world of mainframe there are a number of different solutions for unit testing, one of them being IBM’s zUnit, which uses the xUnit architecture to allow the authoring of tests for COBOL and PL/I code. Following the xUnit architecture allows the tests called and their results to be captured in a variety of popular DevOps tools and IDEs.

Versioning zUnit Artifacts in CA Endevor

zUnit produces a number of different artifacts for each test. For example, it creates files with the test data, it creates the tests themselves and it also generates stubs for programs that are called. One challenge that customers often ask me about: the artifacts generated in a given test can have the same names as in other tests, but different contents — given that, how are these artifacts best versioned in CA Endevor? (Note: this issue is not present with the new IBM Dynamic Test Runner for z/OS introduced in IDz v14.2.1)

Artifacts in Endevor are classified under Systems, Subsystems and Types. It makes sense that the test artifacts would be in their own types but how do we deal with artifacts for different tests having the same name? You might be able to put each test in it’s own subsystem but that would be a lot of administrative overhead.

Serializing Test Artifacts for CA Endevor Storage
Serializing Test Artifacts for CA Endevor Storage

One solution to this problem would be to serialize the artifacts for a given test into a single file before adding it to Endevor. By doing so, you can store each test in the same system/subsystem structure the code uses, but under a dedicated “test” type. When you need to run the tests, you would retrieve them from Endevor, and for each test, you would deserialize the artifacts to their original format and structure, run the tests and clean up afterwards. To ensure no name collisions are created, each test should be initially created (and later deserialized) under its own high-level qualifier so artifacts with the same name don’t overwrite each other.

Serializing and Deserializing zUnit Tests for Management under CA Endevor

So how would we go about serializing and deserializing the artifacts? We’ve come up with a utility that can do just that — a simple REXX script that can serialize a set of PDS’s under a given high-level qualifier to a single file or do the reverse to deserialize it.

It works as follows:

  • Allows the selection of a dataset high-level qualifier, a single testcase and optional additional members using the COMPRESS JCL.
  • Reads the zUnit (AZUGEN) dataset to find files and members that are related to the single testcase.
  • Serializes related files and members, and any manually selected members, to an output file in an encrypted format. This output file can then be checked into Endevor.
  • Later, when the test needs to be run, the serialized file is extracted to a different high-level qualifier that is provided in the EXPAND JCL.

You can find a sample of the script & JCL here.

Note: while we’ve made every effort to ensure this works with zUnit artifacts and are confident it does, this utility is provided as is and should be considered field-developed and not supported as part of CA Endevor. You are welcome to use it as is and we hope it proves useful for working with zUnit and CA Endevor.

Automating your Tests

You may also be wondering how to best make this part of your automated pipeline? One option is to leverage Zowe CLI. Zowe CLI is a framework for executing mainframe operations via a command line interface. The CA Endevor plugin for Zowe CLI lets you perform Endevor operations from the command line. With a Zowe CLI script, you can extract the tests from CA Endevor, deserialize them and then submit them for execution, cleaning up once the tests are done. Here is a sample script that does this for Jenkins

Summary

A quick recap of what we’ve covered:

  • zUnit is an IBM tool for creating COBOL and PL/I unit tests
  • zUnit has the potential to create name collisions between test artifacts
  • A utility to serialize / deserialize the artifacts will help you version them in CA Endevor and keep the tests with the code
  • The utility and the tests can be incorporated into your automation and CI/CD pipelines

Hopefully this has helped solve some of the challenges associated with unit testing with zUnit code.

Learn more about Zowe at this site; more Zowe blogs here.

For more information on the CA Endevor Plug-in for Zowe CLI visit: CA Endevor Zowe CLI Plug-in Documentation.

If you have any questions or feedback or would like to talk about any of your CA Endevor use cases, please feel free to contact me at Vaughn.Marshall@broadcom.com.

Special thanks to Dan Walther for assistance with the scripts.

--

--

Vaughn Marshall
Modern Mainframe

Product manager for Endevor — interested in making developers lives easier through modernization innovation