API Test Automation
by @huahuaweiwei
Generate complete automated API test cases from interface documentation such as OpenAPI, Swagger exports, Postman collections, Markdown API docs, or endpoint...
clawhub install my-api-test-automationπ About This Skill
name: api-test-automation description: Generate complete automated API test cases from interface documentation such as OpenAPI, Swagger exports, Postman collections, Markdown API docs, or endpoint tables. Use when Codex needs to analyze interface docs, generate executable API test cases, add configurable pre-request scripts and post-response assertion scripts, adapt the suite to a user-provided runtime environment, execute the generated tests, and produce a complete test report with pass/fail details, diagnostics, and environment summary.
API Test Automation
Overview
Use this skill to turn API or interface documentation into an executable automated test suite. Always carry the work through end-to-end: understand the API spec, generate complete test cases, wire pre-request and post-assertion logic, execute the suite in the requested environment, and emit a complete report.
Workflow
1. Identify the input artifacts. 2. Normalize the execution environment. 3. Generate the test workspace and test cases. 4. Add pre-request scripts and post-response assertion scripts. 5. Execute the suite in the requested environment. 6. Produce the report and call out gaps or assumptions.
Step 1: Identify the Input Artifacts
Accept any of these as the source of truth:
Before generating tests, extract at least:
If the documentation is partial, continue by making explicit assumptions and record them in the final report.
Step 2: Normalize the Execution Environment
Read environment-contract.md when the user provides runtime or environment details or asks to execute the generated suite.
Capture these items before execution:
postman, newman, pytest, or another user-mandated runnerPrefer these execution strategies:
newman when the user environment already relies on Postman collections or JavaScript test scripts.pytest plus requests when the user wants Python-based suites or the environment clearly supports Python better.Step 3: Generate the Test Workspace and Cases
Run scripts/prepare_test_workspace.py to create a stable workspace skeleton before filling in test logic.
Example:
python scripts/prepare_test_workspace.py --output C:\work\api-test-output --runner postman --env-name sit
Then populate the generated workspace with:
Always create or update case-manifest.json so the report stage can map results back to endpoints and coverage.
Step 4: Add Pre-request and Post-assertion Logic
Use templates from assets/templates/ when you need a quick starting point.
Pre-request logic should handle things like:
Post-response assertion logic should validate both transport and business semantics:
Keep environment-sensitive values in config or env files rather than hard-coding them into each case.
Step 5: Execute the Suite
If the user asks to run the suite, execute it in the provided environment after confirming the runner and prerequisites from the available local context.
Execution checklist:
newman, node, python, pytest, and so on)If the environment is missing a dependency, report the exact blocker and, when appropriate, suggest the minimal install command.
Step 6: Produce the Report
Run scripts/build_test_report.py after execution to generate a human-readable summary and machine-readable JSON report.
Example:
python scripts/build_test_report.py --manifest C:\work\api-test-output\case-manifest.json --results-dir C:\work\api-test-output\reports --output-md C:\work\api-test-output\reports\test-report.md --output-json C:\work\api-test-output\reports\test-report.json
The final report should include:
Resources
scripts/prepare_test_workspace.py
Create a reusable output skeleton with config, report, and script directories plus a starter case-manifest.json.
scripts/build_test_report.py
Merge execution artifacts into a complete Markdown and JSON report.
references/environment-contract.md
Read when runtime or environment details are provided or when deciding how to execute the generated tests.
references/report-contract.md
Read when you need the expected report sections or result-file shape.
assets/templates/
Use starter templates for environment config, pre-request script, post-assertion script, and test-plan notes. Copy and adapt them instead of re-creating boilerplate.