# Test cases (/docs/guides/test-cases)



A decision can carry **test cases**: an input and what the answer must be (`status`, `decision`,
a subset of `outputs`, `actions` that must be requested, or an expected `errorCode`).

Only what a case states is checked, so adding an output does not break every case written before it.

## Save a simulation as a case [#save-a-simulation-as-a-case]

In the simulator, after a run that looks right, choose **Save as case**. The current input and the
output you saw (with status, decision, the actions it requested) become a case the publish must keep
reproducing.

## Mocks [#mocks]

Cases can:

* Fix the clock (`mocks.now`) so a case that depends on `$now` is reproducible.
* Answer outbound calls from canned responses (`mocks.http`) so the case runs without the network
  and unmatched calls fail instead of reaching the outside world.

## Gates the publish [#gates-the-publish]

Every enabled case runs **before** a publish, against exactly what is about to be published
(pinned tables and sub-decisions, frozen constants). A single failure refuses the publish with
`422 TESTS_FAILED` and the full report. The report of a successful publish is stored on the
version.

Test runs persist nothing and enqueue no action. Restoring an old version skips the cases on
purpose — a rollback must not be blocked by cases written for the newer logic — and the audit log
records that they were skipped.
