A coding agent finishes a task and ends its summary with the line everyone wants to read:
All tests pass.
There's one follow-up question worth asking every time: how many of them ran?
Here is a test file with three tests. Every one of them fails if it runs.
# test_checkout.py
import os
import pytest
pytestmark = pytest.mark.skipif(
not os.environ.get("DATABASE_URL"),
reason="needs a database",
)
def test_total_includes_vat():
assert False, "never runs without DATABASE_URL"
def test_discount_is_applied_once():
assert False, "never runs without DATABASE_URL"
def test_refund_restores_stock():
assert False, "never runs without DATABASE_URL"
And here is pytest 9.2 on a machine with no DATABASE_URL:
$ pytest -q
sss [100%]
3 skipped in 0.01s
$ echo $?
0
Zero tests ran. Exit code zero. For any script, CI job or agent that checks $?, that was a successful test run.
Jest 30.5 does the same with the usual "only when there's a database" pattern:
// checkout.test.js
const describeDb = process.env.DATABASE_URL ? describe : describe.skip;
describeDb('checkout', () => {
test('total includes VAT', () => {
throw new Error('never runs without DATABASE_URL');
});
// ...and two more like it
});
$ npx jest
Test Suites: 1 skipped, 0 of 1 total
Tests: 3 skipped, 3 total
Snapshots: 0 total
Time: 0.448 s
Ran all test suites.
$ echo $?
0
"Ran all test suites." It ran zero of one. Ask for the machine-readable version with --json and you get "numPassedTests": 0, "numPendingTests": 3 and "success": true.
The runner isn't wrong
Skipping by default is a sane design for the person it was designed for: a developer at their own machine. You see the yellow sss, you remember you never installed Postgres on this laptop, you shrug. CI will run the real thing later.
Both runners even guard the case next door. If your filter matches no tests at all, pytest exits with code 5 and Jest prints No tests found, exiting with code 1. So somebody already decided that "nothing ran" shouldn't look like success. A skipped test just doesn't count as nothing.
Why an agent makes it worse
An agent works in a fresh container. No database, no Redis, no browser binary for the end-to-end suite. That is exactly where all the "skip if the thing isn't there" branches fire. A suite that runs in full on your laptop can be half asleep in there.
The one reading the output is a model trying to decide whether it's done. Exit code 0 is the strongest "done" signal it will ever get, and it gets it.
And you don't read the output. You read a summary of the output. 3 skipped in 0.01s becomes "the test suite passes" in a single paraphrase, and nobody in that chain lied. The runner reported the skips. The agent reported success, as the exit code told it to. The information just didn't survive the trip.
What to do about it, cheapest first
1. Make skips fail where the environment is supposed to be complete
A skip caused by a missing service is fine on a laptop. In CI, or in the container you built specifically so an agent can run the tests, it means the environment is broken. That should be loud.
For pytest, a few lines in conftest.py turn skips into errors when you ask for it:
# conftest.py
import os
import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
if os.environ.get("NO_SKIPS") and report.skipped and not hasattr(report, "wasxfail"):
reason = report.longrepr[2] if isinstance(report.longrepr, tuple) else report.longrepr
report.outcome = "failed"
report.longrepr = f"skip is not allowed in this run: {reason}"
$ NO_SKIPS=1 pytest -q
EEE [100%]
==================================== ERRORS ====================================
__________________ ERROR at setup of test_total_includes_vat ___________________
skip is not allowed in this run: Skipped: needs a database
[...]
3 errors in 0.01s
$ echo $?
1
The wasxfail check leaves expected failures alone, so xfail keeps working.
Jest has no flag for this, but the JSON report has the number:
$ npx jest --json --outputFile=result.json
$ node -e "const r = require('./result.json'); if (r.numPendingTests > 0) { console.error(r.numPendingTests + ' tests did not run'); process.exit(1); }"
3 tests did not run
You will still want some skips (Windows-only tests, the flaky one in quarantine), so keep it a switch and flip it only in places where a skip means something is missing. If you can't flip it yet, at least run pytest with -rs. It prints every skip with its reason at the end of the run instead of a row of s.
2. Ask for counts, not adjectives
If you give your agent written rules (CLAUDE.md, AGENTS.md, a system prompt, whatever your tool reads), "make sure the tests pass" invites exactly the sentence this post started with. Ask for something you can check:
When you report test results, give for each command you ran: the exact command,
its exit code, and how many tests passed, failed and were skipped.
List every skipped test with its reason.
Never describe a run with skipped tests as "tests pass".
You can't verify "all tests pass" from where you sit. You can verify "pytest -q: 41 passed, 3 skipped (needs a database), exit 0", and it tells you where to look.
A rule in a prompt is still only a request, which is why this is number two and the conftest is number one.
3. Give the report a third state
Most reports have two outcomes, passed and failed. "Couldn't check" has to land in one of them, and it never lands in failed.
So add a third. For each thing the change was supposed to do:
| Criterion | Result | Evidence |
|---|---|---|
| Order total includes VAT | passed |
test_total_includes_vat, ran against Postgres |
| Discount code applies once per order | unverified | test skipped: needs a database |
| Expired code shows an error message | passed | test_expired_code_message |
Unverified doesn't block anything by itself. It hands a decision back to you: check it by hand, or fix the environment so it can be checked next time. For a copy change, by hand is fine. For money math I'd wire up the database.
If you can, don't let the session that wrote the code write this report. It already believes the code works. A fresh session that gets only the diff and the criteria has less to defend.
Where I ended up
Disclosure: I build Mergehand. It runs coding agents on your own machine and takes a ticket to a merge request, with a person approving the plan and then the result. So I had to pick a side on all of the above, and the test step works the way I just described. A fresh agent that didn't write the code checks every acceptance criterion from the approved plan and reports it as passed, failed or unverified, with evidence. The repository's own checks get a separate table, where "not run" is a legal value with the reason next to it.
Look at the last row: visual regression, NOT RUN, no browser on the runner. Anywhere else that row would have been a quiet skip. There's a click-through example task with the whole report if you want to poke at it, no signup needed.
None of the three fixes needs my tool, or any tool. The conftest is a dozen lines. Start there.
What does your runner do?
The reproductions above are pytest 9.2 and Jest 30.5. What does your stack do with skips in CI? I'm curious about Go's t.Skip, RSpec's pending and PHPUnit in particular, and whether anybody uses a runner where "everything was skipped" fails by default.
Written with AI assistance. Every command and output in this post was actually run.

Top comments (0)