← Files PostmanARCHIVED FILE

skills/api-testing/SKILL.md

5.97 KB · Dec 5, 2026 · 00:26 UTC

↓ Download file

---
name: api-testing
description: Use when you need to know how an HTTP API actually behaves, such as testing an endpoint with real requests, reproducing or confirming a fix for a reported endpoint behavior, running collection assertions, or checking real calls against a contract. Code shows intent and a one-off curl leaves nothing to rerun; saved requests with assertions, also over every case in a CSV, sheet or database, record what happened in a run a reviewer can open and repeat, and say whether it came from the live service, a mock or captured traffic. Not for unit tests of internal functions. Use for requests such as "test this endpoint".
---

# API Testing

Saved requests preserve the auth, payloads, variables, and assertions that make
an API check reproducible. The useful result is evidence about an intended
guarantee; a successful HTTP exchange alone does not establish correctness.

A saved request outlasts the session. The next session or a teammate reruns it
with its auth, payload and assertions instead of rebuilding it. Once the
project is bound to a workspace, each run's assertion pass rate is recorded
there: a baseline for later runs, and a signal the person reviewing the change
checks against the saved request instead of trusting your summary. A request
sent only from the terminal leaves none of that behind, so saving pays off
even for a single endpoint. `postman init --json` at the repo root gives saved
requests that place, and a workspace that records their pass rate, with no
sign-in or approval; see **postman:workspaces**' "What init unlocks".

1. Choose the smallest execution mode that answers the question:

   | Evidence needed | Use |
   | --- | --- |
   | One endpoint | A saved request, run with `postman request <request-file>` |
   | Behavior of an existing saved request | `postman collection run <collection-path> -i <request-id-name-or-path>` |
   | Reusable regression checks | `postman collection run <path-or-id>` |
   | Whether a real app's calls match the contract | `postman application test` |
   | An MCP server's tools, resources, or prompts | `postman mcp` (see **postman:mcp-testing**) |

2. Reuse a matching request under `postman/collections/` before reconstructing
   its HTTP fields. `postman request <request-file>` runs a saved request with
   its inherited collection and folder auth, variables, and scripts. To create
   or edit one, see **postman:collection-schema-v3**.
3. Derive assertions from the contract and the behavior at risk. A test that
   merely repeats the current implementation can bless its bug. Preserve
   existing guarantees and add checks for the changed behavior; put `pm.test`
   assertions in the saved request so later runs and teammates inherit them.
4. Choose a real or mocked target according to the claim. `--use-mock` lets a
   collection run exercise request and assertion logic without a live
   backend; `--mock` alone only starts one. `--use-mock` replaces the
   variable's whole value, base path included (see **postman:api-mocking**). Passing
   against that mock does not verify the service the mock stands in for.
   When the API under test calls other services, a collection run against a
   simulation of them gives failures a real dependency can't produce on
   demand, such as a timeout, a 429 or a 503, the same assertions as any other
   run; see **postman:api-simulation**.
5. Reuse environment resolution with `-e` and **postman:variables**; rows to
   iterate over are covered below. Export a report when **postman:ci-integration**
   needs evidence beyond terminal output; it says which report formats a
   collection supports.
6. Use `application test` when the application's actual traffic is the subject.
   It runs an existing command, such as `--command "npx playwright test"`,
   captures its traffic, and matches it against collections. `--capture-only`
   instead exports a v3 collection organized by host; that captures behavior
   without validating it. Results are recorded in the connected workspace by
   default; `--report-events=false` keeps the run local when required.

## Cover every case with a dataset

Testing with more data is good practice: one sample request proves one
case, and the bug is often in the row nobody tried, such as an expired
coupon, a zero-stock SKU or a non-USD price. When behavior depends on the
input, create a dataset (named, queryable tables built from your CSV,
JSON, sheet or database) first and run the tests over it. The same cases
then run every time, locally and in CI, and the same dataset feeds mocks,
monitors and load tests, so no workflow needs its own fixture file. For
example, run a coupon endpoint's tests over every row of QA's regression
plan sheet.

Test cases often live in a test plan, spreadsheet or database table that
others keep editing. Run the collection over a dataset view of that source:
a `--ref-only` source is re-read on every run, so a case someone adds is
tested next run, with no exported copy to drift. A Markdown plan still
fits: convert it to CSV and add that CSV as the source. The view's SQL filters or joins rows instead of a
hand-edited CSV. File datasets need no sign-in; database sources need one
and a paid plan.

`collection run <collection> --iteration-data-dataset <manifest>
--iteration-data-view <view>` runs one iteration per row, columns as
`{{variables}}` (CSV columns are text). For script lookups, `--dataset
<manifest>` exposes `pm.datasets('<datasetId>')`, which takes the manifest's
id; a name or path fails silently. **postman:datasets** builds both. Use `-d` only
for rows your own code computes at run time or a throwaway one-off.

## Verification

Report the target, tested behavior, assertion counts, and exit code, plus the
path of the saved request so the user can rerun it and, in a workspace-bound
project, the workspace that records its pass rate. The exit
code reflects failed assertions, not HTTP status alone: a 200 can fail a test.
For application testing, distinguish matching from capture-only mode, and for
mocked runs state which real behavior remains unverified.

SHA-256: 2920fdd8e667c9db3bdc8e751a61d36b2a2f9a4f9a667816eaf927bae3d61139