con un clic
backend-testing
// Use when writing, debugging, or maintaining tests for the native C/C++ and Metal C components in native/c/test/. Covers the custom ztest framework, test patterns, build system integration, and debugging test failures.
// Use when writing, debugging, or maintaining tests for the native C/C++ and Metal C components in native/c/test/. Covers the custom ztest framework, test patterns, build system integration, and debugging test failures.
Improve TypeScript code quality in CLI, SDK, and VS Code extension packages. Apply DRY, YAGNI, SRP principles to reduce duplication and complexity. Use when refactoring, deduplicating, simplifying, or improving code in packages/cli/ or packages/sdk/.
Review pull requests for the zowex codebase. Analyze C++ backend and middleware (ibm-clang), TypeScript clients (CLI, SDK, VS Code extension), and z/OS-specific concerns. Use when asked to review a PR, branch, or code changes.
Validate VS Code extensions and CLI plug-ins against Zowe V3 Conformance Criteria. Audit package.json, settings, commands, menus, profile usage, and API registration for conformance. Use when checking Zowe conformance, preparing for conformance submission, auditing an extension/plug-in against Zowe criteria, or when the user mentions conformance.
Guides users through creating new zowex commands across the Zowe Remote SSH stack (native C++, server, SDK). Use when the user wants to add a new command, implement a zowex command, or add functionality to the native backend.
Improve C++ code quality by identifying duplication, complexity, and design issues. Apply DRY, YAGNI, SRP principles. Use when refactoring, deduplicating, simplifying, or improving backend code in native/c/.
Prevent data loss and unsafe operations in data set and USS workflows, including cross-profile, cross-LPAR, and overwrites. Use when performing move, copy, upload, rename, or delete operations on z/OS resources.
| name | backend-testing |
| description | Use when writing, debugging, or maintaining tests for the native C/C++ and Metal C components in native/c/test/. Covers the custom ztest framework, test patterns, build system integration, and debugging test failures. |
Testing native C/C++ and Metal C components using the custom ztest framework (Jest-like C++ testing, not Google Test).
File Structure:
native/c/test/*.test.cpp - C++ unit testsnative/c/test/*.metal.test.c - Metal C testsztest.hpp - Custom Jest-like frameworkztest_runner.cpp - Main test runnerKey Features: describe(), it(), Expect().ToBe(), signal handling, timeouts, XML output.
#include "ztest.hpp"
#include "../my_module.h"
using namespace ztst;
void my_module_tests() {
describe("module", []() {
it("should work", []() {
Expect(my_function(5)).ToBe(10);
});
it("should handle errors", []() {
Expect([]() { bad_function(); }).ToAbend();
});
});
}
Add to runner: Include header in ztest_runner.cpp, call my_module_tests() in main callback, update makefile with object file.
Expect(result).ToBe(expected);
Expect(result).Not().ToBe(unwanted);
Expect(str).ToContain("substring");
Expect(num).ToBeGreaterThan(5);
Expect(ptr).ToBeNull();
Expect(lambda).ToAbend(); // Test crashes
ExpectWithContext(val, "debug info").ToBe(expected);
TEST_OPTIONS opts = {
.remove_signal_handling = true, // Disable crash detection
.timeout_sec = 30 // Custom timeout
};
it("test name", []() { /* test */ }, opts);
// Conditional skip
#ifdef RELEASE_BUILD
it("test", []() { /* runs */ });
#else
xit("test", []() { /* skipped */ });
#endif
# Local
cd native/c/test && make test
./build-out/ztest_runner "pattern" # Filter tests
# Remote z/OS
npm run z:test
npm run z:test "pattern"
# Debug
export ZNP_TEST_LOG=ON BuildType=DEBUG
make clean && make test
Crash investigation:
TEST_OPTIONS opts = { .remove_signal_handling = true };
// Shows actual crash dump instead of catching
Timeout issues:
TEST_OPTIONS opts = { .timeout_sec = 60 };
Debug logging:
TestLog("Debug message"); // Only shows if ZNP_TEST_LOG=ON
Command testing:
int rc; std::string output;
rc = execute_command_with_output("zowex version", output);
ExpectWithContext(rc, output).ToBe(0);
Metal C test file: module.metal.test.c
extern "C" int test_metal_function() {
// Metal C test logic
return 0; // success
}
Call from C++ test:
it("metal test", []() {
Expect(test_metal_function()).ToBe(0);
});
| Variable | Purpose |
|---|---|
ZNP_TEST_LOG=ON | Enable debug logging |
BuildType=DEBUG | Debug build |
FORCE_COLOR=1 | Force colors |
Exit codes: 0 = pass, 1 = failures. Generates test-results.xml for CI.