Testing rules for coding agents
How to tell an agent when to add tests, which runner to use, and how to keep a Cursor testing rule off the always-on path.
Say which runner, and when
Agents invent Jest in a Go repo and skip tests in a repo that has a strict suite. Name the runner and the command. Say whether you want a test for every behavior change, a test-first workflow, or no new framework at all.
A Cursor project can split this out. The always-on rule names the stack. `.cursor/rules/testing.mdc` sets alwaysApply to false and globs to the test files, so the testing policy shows up when someone is editing tests.
Demand a useful test
Ban the fake coverage agents like: a snapshot of an entire page, a test that mocks the function under test, or a download of a real dataset. Ask for one success and one failure on the boundary that changed. For games and engines, a pure function test beats booting the whole player.
Do it in this order
01
Name the command
pytest, go test, dotnet test, flutter test, cargo test, or the npm script you actually have.
02
Choose a stance
No new framework, pragmatic tests on behavior changes, or test-first.
03
Point globs at tests
In Cursor, keep that rule out of alwaysApply.
04
Reject a bad test in review
The rule sticks when a snapshot-only test is sent back.
Questions
Should agents add tests if the repo has none?
Only if you asked for that. A 'do not introduce a test framework' line prevents a surprise dependency.
Where does this go in AGENTS.md?
A Testing section next to Commands is enough. Repeat the command in both places.