Skip to main content

Test Plans

A recording shows what your service did. A PRD or a ticket says what it should do. A test plan joins the two: each requirement in its source's words, with the requests that prove it.

proxymock checks a plan against the recorded traffic and your OpenAPI spec, says how to close each gap, and after a replay reports whether every requirement was met.

proxymock never decides what a requirement means. You, or your coding agent with the test-plan skill, write the plan. Every check proxymock makes compares requests and statuses.

Write a plan​

Plans live in the workspace, at proxymock/plans/<name>.yaml. Start from a template:

proxymock plan init checkout

Replace the example with your requirements:

name: checkout
source: PRD "Checkout v2"
requirements:
- id: R1
text: A shopper sees the price of an item, tax included.
source: PRD 2.1
cases:
- id: R1.1
category: functional
request: GET /price?item={sku}
expect: {status: 200}
- id: R1.2
category: negative
request: GET /price?item=does-not-exist
expect: {status: 404}
- id: R2
text: A shopper can cancel an order.
cases:
- id: R2.1
category: functional
request: DELETE /orders/{id}
expect: {status: 204}
FieldHolds
nameThe plan's name
sourceWhere the requirements come from
requirements[].id, text, sourceOne requirement, in its source's words, and the passage it comes from
cases[].idA name for the case, unique in the plan
cases[].categoryfunctional, contract, negative, auth, journey or load
cases[].requestMETHOD /path?query. A path segment written {name} or * matches any one segment. A query parameter must be present with that value, or with any value when written {name}
cases[].expect.statusThe status the request must get, such as 201, or a class, such as 4xx. Leave it out to accept any status
cases[].notesWhat the case needs that the request alone does not say, such as "an order that does not exist"

Check a plan​

proxymock plan check --plan checkout --in proxymock/recorded

Each case comes back in one of four states, with what closes the gap:

StateMeaningTo close it
coveredThe recording has the request, answered with the expected statusNothing
contradictedThe recording has this exact request, but never with the expected statusRecord it again once the service meets the requirement, or check that the expected status is right
spec-onlyThe OpenAPI spec documents the operationWrite the request with proxymock generate, then send it through proxymock record
uncoveredNothing in the workspace sends the request, or a templated request was only recorded with other statusesSend a request through proxymock record

For negative and auth cases, request variations write the requests from the recorded ones: a request with no credential, with another user's credential, or with bad input. Check the plan against both recordings with --in proxymock/recorded,proxymock/variations.

Only a case that names one exact request can be contradicted. A templated case such as GET /orders/{id} expecting 404 is not contradicted by another order that answered 200: that recording was sent other input.

The spec is the workload's spec in proxymock/applications/ when there is one, or the file --spec names.

FlagUse it to
--planName the plan: a file, or a name in proxymock/plans/
--inName the recordings to look in
--specName the OpenAPI spec
--jsonWrite the result as JSON
--fail-on-gapsExit 1 unless the recording covers every case, which gates a pipeline on the plan being testable

The test_plan MCP tool runs the same check for a coding agent.

Replay with a plan​

proxymock replay --in proxymock/recorded --test-against localhost:8080 --plan checkout --test-config regression

A case is the replayed requests whose recording is the case's request with the expected status. Each requirement gets a result:

ResultMeaning
passedEvery case's requests answered as recorded
failedA request of one of its cases did not answer as recorded
not-runA case had no replayed request, so the requirement was not fully exercised

The results go in four places:

  • plan-result.json in the replay output, with each case's replayed and failed counts.
  • A Requirements section in replay-summary.md, failed requirements first, which a pull request comment shows.
  • A requirements suite in the JUnit report, with a test case per plan case. A case that was not exercised is skipped.
  • The failure bundles, where each failed request names the requirement it breaks, and its fix prompt says so.

The plan does not change the exit code: a failed requirement already failed its requests. Use proxymock plan check --fail-on-gaps before the replay to fail on requirements nothing tests.

A requirement is judged on the recording. After a change that meets a new requirement, a case recorded from the old behavior fails. Record it again and replay.

Loading search...