# Running tests

`jadpo test` runs every test in the project, and owns everything a run
needs, so nothing about it appears in your source. It starts a disposable
local PostgreSQL, from the PostgreSQL programs installed on your machine, or
uses `JADPO_TEST_DATABASE_URL` in CI. It builds one template database from
the migrations and copies it for each test, so tests run in parallel
([The test database](/docs/the-test-database.md)). `--keep-failed` keeps a failed
test's database. The report lists each failed test with the failure it got
and the one it expected.

To run fewer, name them:

- `jadpo test <file>` runs one file;
- `jadpo test <file>:<line>` runs the test at that line;
- `--name <text>` runs the tests whose names match;
- `--kind route` runs one kind;
- `--failed` runs the tests that failed last time. When every test that
  failed last time is gone, there is nothing to rerun and the run passes.

There is no `test.only` in source: focusing is a command-line choice, so
a focused test is never committed by accident.

## Watch mode: `--watch`

`jadpo test --watch` reruns, on every save, the tests the change reaches.
It finds them with the compiler's own dependency graph
([`jadpo test`](/docs/the-jadpo-command.md#jadpo-test)).

## Interactive mode: `--interactive`

`jadpo test --interactive` opens a keyboard-driven view of every test in
the app, grouped by domain and file, with each test's last result. You
type to search files and tests; run a file, a single test or everything;
rerun failures; open a failure's full report; and turn watch mode on and
off. It needs a terminal, so agents use the flags above and `--json`.

## Paths in the output

A failed test's rerun command, and every path a run prints, work from the
folder the command ran in. Run from outside the project, they start with
the project as it was typed (`examples/07-testing/domains/…`).

## In the editor

The editor shows a run button above each test and the last result beside
it, through the language server.

Interactive mode isn't built yet: `--interactive` says
`toolchain.not_built_yet`. Use the flags above, or `--watch`, for now.

Not built yet: `--affected`, which runs the tests a change reaches. Nor are
the tests the compiler is to generate from facts it already has, run with
your tests and shown in the report under the route they test:

- every route refuses bad input with `{ field, rule }` details;
- every declared failure reaches the client in the right envelope and
  status;
- no output has a field its type doesn't declare.
