testing

A set of testing rules for code changes. It distinguishes unit tests for isolated logic, integration tests for connections such as databases or APIs, and end-to-end tests for complete user flows.

In plain words
What is it for?
Planning tests for features, bug fixes, and refactors. It sets coverage priorities and asks for a small runnable check for each new piece of logic that needs testing.
Why use it?
It helps prevent untested input handling, authentication checks, public interfaces, error paths, and edge cases. It also avoids using slow end-to-end tests where a smaller test is enough.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/mhmdreza-rafiei/agent-tools/testing
Clone the repo
git clone --depth 1 https://github.com/mhmdreza-rafiei/agent-tools
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 425 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00025 $0.00425
Opus 5 $0.00013 $0.00212
Sonnet 5 $0.00005 $0.00085
Haiku 4.5 $0.00003 $0.00042

Measured 3d ago against content hash 3a0f36ad373e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/code/testing.mdc · 47 lines

What it actually says

Testing

Applies when writing or changing code that should be tested. Load for features, bug fixes, refactors. Not every chat.

What must be tested

  • Trust boundaries — every input parser, validator, and auth check has tests. Untested trust boundaries ship vulnerabilities.
  • Branches that can fail silently — error paths, edge cases, empty inputs, off-by-one. The happy path is the last to test, not the first.
  • Anything with a public contract — exported functions, API endpoints, CLI flags. If a caller can reach it, it has a test.

Coverage

  • Coverage is a floor, not a goal. Aim for the trust boundaries and public contracts at 100%; ignore the rest unless the project sets a bar.
  • A new line of logic leaves the smallest runnable check behind (assert- based demo or one small test). Trivial one-liners need no test.

Unit vs integration vs E2E

  • Unit — pure logic, fast, no I/O. The default.
  • Integration — when the bug is at the seam (DB, API, file system). Use when unit tests would mock the thing that's actually broken.
  • E2E — for user-facing flows that have failed before. Don't E2E what a unit test already covers; E2E is slow and flaky.

Bug fixes

  • A bug fix lands with a test that fails before the fix and passes after. No reproducer test → the bug will regress.

Do not

  • Test implementation details that should be free to change.
  • Mock what you don't own to the point the test proves nothing.
  • Skip the failing path because it's hard to set up — that's the path that ships bugs.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 47 lines · 25 tokens per session scan A 3a0f36ad373e

Subscribe to this mod's changes

testing is a cursor rule published in the GitHub repository mhmdreza-rafiei/agent-tools (5 stars, last pushed 15d ago), licensed MIT. It adds 25 tokens to every session and 425 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.