Route coverage
outry coverage answers “which endpoints of the service are not tested at all”. It reads the routes from
the Go or Rust code (as outry import go and
outry import rust), matches them with the requests in the
project and looks at their expect blocks. Nothing is sent.
outry coverageGET /health no request codes 0/1 main.go:9POST /orders no expect codes 0/1 api/orders.outry:5 unchecked: 201DELETE /orders/{id} no expect codes 0/1 api/orders.outry:9 unchecked: 204GET /orders/{id} checked codes 1/2 api/orders.outry:1 unchecked: 404
1/4 routes checked (25%): 2 without expect, 1 without request; 1/5 status codes checked1 missing request can be created with `outry import go`Levels
Section titled “Levels”Every route gets one of three levels:
| Level | Meaning |
|---|---|
no request |
The route is in the code, but no .outry or .http request points at it. outry import go creates one. |
no expect |
There is a request, but nothing checks its response. |
checked |
A request to the route has expect — its own, or a check of its result somewhere else. |
A request matches a route the same way as in outry import go: by handler:, otherwise by method and
path. The percentage is the share of checked routes.
A request counts as checked when:
- it has an
expectblock itself; - another request or a flow checks its result:
expect { GetOrder(id: body.id).body.status == "new" }; - a flow binds it and checks the binding:
order = CreateOrder()…expect { order.status == 201 }; - in
.http, it has a> assertline.
A request called only for a value — Login() in a header — is not a check of Login.
Status codes
Section titled “Status codes”Outry also collects the status codes each handler responds with:
net/httpconstants anywhere in the handler:http.Error(w, "…", http.StatusConflict),c.JSON(http.StatusNotFound, …)(the same names in fiber and iris);- numbers from 100 to 599 passed to response calls:
c.JSON(404, …),w.WriteHeader(201),c.AbortWithStatus(401), your ownrespond(w, 409, …); - a handler without any success code answers
200— that code is marked as implicit.
A code is checked when some request to the route compares the status with it:
GetOrder: GET /orders/{id} { expect { status == 200 }}
flow MissingOrder { expect { GetOrder(id: 0).status == 404 }}status == 404, 404 == status and status in [200, 404] count; ranges (status < 500) check the response
but do not mark a specific code. Codes set inside helper functions the handler calls are not found.
Executed routes
Section titled “Executed routes”Static coverage says a request exists and checks something, not that it actually ran. Add a run log to see
which routes were really called — directly or from another request (Login() in a header) or a flow:
outry run api --coverage-out run.jsonoutry coverage --from run.jsonPOST /login no expect ran codes 0/1 api/orders.outry:1 via CreateOrder unchecked: 200POST /orders checked ran codes 1/1 api/orders.outry:5DELETE /orders/{id} no expect not run codes 0/1 api/orders.outry:15 unchecked: 204GET /orders/{id} checked ran codes 2/2 api/orders.outry:10 via Missing
2/4 routes checked (50%): 2 without expect, 0 without request; 3/5 status codes checked; 3/4 routes executed (75%)--coverage-out writes every request that was actually sent: its file and name, method, URL, the status
that came back and, for a call, the chain it was called from. Responses taken from the run cache are not
sent and not written. A logged request is matched with the route through the request in the project
(by file and name, so later edits don’t break it; .http by file); if the request is gone, by method and
URL path. via shows that a route was only reached indirectly.
--from can be repeated to merge logs, for example from several CI jobs or environments. In JSON, every
route gets executed (and via), every status code seen — whether that code actually came back.
--min-executed <N> fails below N percent of executed routes, and --uncovered also lists the routes
that were not run.
Options
Section titled “Options”outry coverage [DIR] [--min <N>] [--from <FILE>]... [--min-executed <N>] [--uncovered] [--format text|github|json]DIR is the Go or Rust service. By default it is the folder with go.mod or Cargo.toml, searched from
the project up to the repository root.
| Flag | Description |
|---|---|
--min <N> |
Exit with 1 if fewer than N percent of routes are checked |
--from <FILE> |
Run log from outry run --coverage-out: mark executed routes; can be repeated |
--min-executed <N> |
Exit with 1 if fewer than N percent of routes were executed (needs --from) |
--uncovered |
Show only gaps: routes without a request, without expect, with unchecked status codes or (with --from) not executed |
--format <F> |
text (default), github (GitHub Actions annotations), json |
--json |
Same as --format json |
--base <NAME> |
Variable with the service address in .http URLs (for matching), default base |
--query <FILE.scm> |
An extra tree-sitter query for another router; can be repeated |
--project <DIR> |
Project folder with env.toml |
outry check prints a one-line summary of coverage when it finds a go.mod or Cargo.toml. Low coverage is not an
error there; use outry coverage --min to enforce a threshold.
- name: Route coverage run: outry coverage --min 80 --format githubTo also require that the routes really ran, write a log in the test step and pass it on:
- name: API tests run: outry run api --env ci --coverage-out run.json- name: Route coverage if: always() run: outry coverage --from run.json --min 80 --min-executed 90 --format githubWith --format github every gap becomes a warning annotation on the pull request: a route without a request
is marked on its registration in the code, a request without expect on the request, and an unchecked status code
on the line of the handler that returns it; with --from, a route that was not executed is marked on its
request. Below the threshold the job fails with an error annotation.
--format json prints the totals (percent, checked, requested, total, statuses_checked,
statuses_total, passed; with --from also executed, executed_percent) and every route with its level, requests and status codes.
In the desktop app
Section titled “In the desktop app”The Routes tab shows the same coverage: a summary line under the plan, a badge on every route that has
a request (no expect, unchecked 404, checked) and Show N gaps only to hide routes that are fully
checked. Routes without a request are listed under New, and Create files writes them.