QA API Test
Builds API tests the way a QA engineer would: design the cases first, get them approved,
then automate and report. Works with any agent that reads SKILL.md.
Prerequisites
- Python 3.9+ (standard library only)
- Node.js 18+ for Newman:
npm install -g newman newman-reporter-htmlextra(ornpx newman ...without a global install)
Workflow (follow these steps in order)
- Understand the API. Read the spec, curl, or docs the user gives. List each endpoint with its method, auth, required fields, field types and limits. If something important is missing (base URL, auth method, which environment is safe to test), ask before going on. Never run tests against production unless the user says it is allowed.
- Design test cases. For each endpoint, write positive cases first, then walk through
every category in
templates/negative-checklist.md. Put them in a table using the format intemplates/test-case-table.md(ID, category, endpoint, scenario, input, expected result, priority). Show the table and wait for the user to approve or edit it. - Write the spec file. Convert the approved table into
cases.json(format below). Each case has anexpectblock; addexpectedTextwith the human-readable expectation used in the report. - Generate the collection.
python scripts/build_collection.py cases.json -o collection.jsonThe output imports directly into Postman (File > Import). - Run it.
npx newman run collection.json -r cli,json,htmlextra \ --reporter-json-export newman/report.json \ --reporter-htmlextra-export newman/report.html - Report.
python scripts/summarize.py newman/report.json cases.jsonprints a Markdown table (test case, expected, actual, PASS/FAIL). For every FAIL, write a short defect: title, steps (request), expected, actual (status code and relevant body), and severity. A 5xx on bad input, accepted invalid data, and duplicate transactions are at least Major. - Hand over. Give the user
cases.json,collection.json,newman/report.html, and the defect list. Do not "fix" expectations to make tests pass; a failing test is a finding.
Spec format (cases.json)
{
"name": "API Negative Tests - My Service",
"baseUrl": "https://api.example.com",
"headers": {"Content-Type": "application/json"},
"cases": [
{
"id": "TC01", "name": "Missing required field (email)",
"method": "POST", "path": "/users",
"headers": {"Authorization": "Bearer {{token}}"},
"body": {"name": "Andi"},
"expectedText": "400 Bad Request",
"expect": {"status": [400], "noServerError": true}
}
]
}
expect keys:
| Key | Meaning |
|---|---|
status | List of allowed status codes |
noServerError | Fails on any 5xx |
bodyContains / bodyNotContains | Text that must / must not appear in the response |
maxResponseTimeMs | Upper limit for response time |
sameAsVar | {"field", "var"}: response field must equal a saved variable, or the status is 409 (duplicate checks) |
Other case keys: save ({"varName": "responseField"} stores a value for later cases) and
setup: true (a helper request that is left out of the summary table).
Example
examples/restful-booker/ runs 5 negative cases against Restful Booker, a public API made
for testing practice. Result: 1 pass and 4 defects (500 on a missing field, invalid and
negative prices accepted, duplicate booking created). See its README.md.