The Unit Test for Mainframe VS Code extension brings the capabilities of Test4z into your VS Code development environment. Test4z provides capabilities for unit testing, record and replay testing, and code coverage metrics on user mainframe applications. Test4z is built to work with any programming language (such as COBOL, PL/I, C, or Assembler) that produces a mainframe load module. Test4z provides the most benefit for COBOL programs.
The extension includes the following features:
- Execute unit tests
- View code coverage metrics
- Use code snippets to add sample code for the Test4z COBOL API
- VS Code 1.77.0 or higher
- Test4z 1.1.101, including the Command Line Interface (part of the npm package, refer to the Install Test4z Command Line Interface section in the Test4z documentation)
Verify their installation from the CLI:
code --version
t4z --version
Unit Test for Mainframe is supported on Visual Studio Code.
We recommend the use of Zowe Explorer to access mainframe data sets in connection with your testing activities. You can use Zowe Explorer to submit JCL or to edit the recorded data. Zowe Explorer is available as part of the Code4z package. The Unit Test for Mainframe extension works seamlessly with the Code4z extension pack for z/OS application developers.
To initialize a project, perform the following steps from the VS Code menu:
-
Click File > Open Folder... to select and open your folder.
-
Click View > Command Palette... to open the VS Code Command Palette. Select Test4z Initialize.
-
Respond to the prompts to complete the initialization. If needed, see the Initialize the Project section in the Test4z documentation.
To use the Test4z code snippets, a COBOL LSP is required. Install Broadcom's COBOL Language Support or the complete Code4z package. You can configure the COBOL LSP to find the Test4z COBOL API copybooks. This helps with syntax checking of the code and navigation to the copybooks.
The t4z init
command creates the file .vscode/settings.json
with the following content:
{
"cobol-lsp.cpy-manager.paths-local": [
"<path to the Test4z>/cobol_api/cpy"
]
}
If you want to add the path to the Test4z COBOL API copybooks into an existing configuration, perform the following steps:
-
Find the path to Test4z:
t4z home
-
Update the value of the
cobol-lsp.cpy-manager.paths-local
property in the.vscode/settings.json
or cobol-lsp - Cpy-manager: Paths-local in the VS Code Settings (File > Preferences > Settings) so it contains"<path to the Test4z>/cobol_api/cpy"
.
Test4z allows you to run all tests or to run individual tests. In either case, you can choose to run with or without code coverage.
-
Right-click the test directory. A context menu appears.
-
Select Test4z Run All Tests to run the complete set of tests.
or
Select Test4z Run All Tests with Coverage to run the tests along with code coverage analysis.
-
In the test directory, navigate to a specific test file and right-click the file.
-
Select Test4z Run Test for a standard test run.
or
Select Test4z Run Test with Coverage to run the test along with code coverage analysis.
To analyze code coverage in your project, perform the following steps:
-
Execute your tests with the coverage option enabled. The
coverage
folder is created. -
Right-click the
coverage
folder and select Test4z Open Coverage Dashboard. This action opens the Code Coverage panel. -
In the Code Coverage panel, click any program to visualize code coverage at the source code level.
-
Execute your tests with the coverage option enabled. The
coverage
folder is created. -
From the
src
folder, open the specific COBOL source file that you want to examine. The code coverage information is displayed in the editor.
If you want to publish code coverage reports within your CI/CD pipeline, multiple report formats are readily available within the generated coverage
folder.
The Unit Test for Mainframe VS Code extension provides COBOL code snippets that make it faster and easier to create your unit tests. Most of the code snippets directly correspond to the Test4z COBOL APIs. For more information on the Test4z COBOL APIs, see the COBOL API
section in the Test4z documentation
Some snippets contain comments or highlighted variables to assist in customizing the sample code for your test program.
Find and select a snippet:
-
In your COBOL test program, type t4z to view the available snippets. You can also click View > Command Palette > Snippets: Insert Snippet from the VS Code menu.
-
Type additional keywords, like the API name, to narrow the results. The highlighted snippet displays a short description, along with the COBOL code to insert.
-
Select the desired snippet. The code sample is copied to your test program.
The Unit Test for Mainframe VS Code extension is made available to customers on the Visual Studio Code Marketplace in accordance with the terms and conditions contained in the provided End-User License Agreement (EULA).
In the event that Broadcom needs to process your personal data this is done in accordance with Broadcom’s Privacy Notice.
If you are on active support for Test4z, you may be entitled to technical assistance and support in accordance with the terms of your agreement and Broadcom's support policies.
Copyright © 2024 Broadcom. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.