testing

A set of project rules for writing useful automated tests, including tests that check complete code paths and full user flows.

In plain words
What is it for?
It helps decide which behaviors to test, where to place unit, integration, and end-to-end tests, and which existing test tools and conventions to follow.
Why use it?
It prevents tests that only increase coverage numbers or pass because too much code was replaced with mocks.

Cursor rule for Cursor

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/afaraha8403/balakit/testing
Clone the repo
git clone --depth 1 https://github.com/afaraha8403/balakit

Made for: Cursor.

Per session 599 This file is loaded in full into every session.
When invoked 599 The same file — it is already loaded in full.
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.00599 $0.00599
Opus 5 $0.00300 $0.00300
Sonnet 5 $0.00120 $0.00120
Haiku 4.5 $0.00060 $0.00060

Measured yesterday against content hash 6e270c6cf499, 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 yesterday.

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.

.cursor/rules/testing.mdc · 57 lines

How it starts

The opening of the file, as written. The whole thing — 57 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing

Philosophy

Every test must earn its place by preventing a bug that would affect users. Do not write tests to hit a coverage number. If you cannot explain what bug a test would catch, do not write it.

Favor integration tests over unit tests. Test real code paths — input validated, work performed, result returned. Reserve unit tests for complex business logic: pricing calculations, date handling, permission resolution. Do not write unit tests for glue code or tests that mock everything away.

Folder Convention

Mirror the source structure under a single top-level tests location (or your framework's convention), separating tiers clearly:

  • Unit tests — complex business logic only.
  • Integration tests — the default tier for most behavior.
  • End-to-end tests — full-stack flows.

Follow whatever layout the project already uses; do not impose a new one mid-project.

Tooling

  • Use the test runner the project already adopts. Do not introduce an additional test framework without team agreement.
  • Match the existing assertion style, fixtures, and mocking approach.
  • Keep end-to-end tests pointed at a deployed/staging-like environment rather than hard-coded local URLs when the project's flow expects that.

When to Write Tests

A behavior change in a PR requires a test that exercises that behavior. "Behavior change" means: what the user sees or what the API returns is different. Refactors that preserve behavior do not require new tests — existing tests should still pass.

Bug fixes: Write the failing test first. The test is the proof the bug existed and that the fix works.

End-to-End Tests

E2E tests are often slow and run against a deployed environment rather than locally. Do not write E2E tests that assume a local server or a specific hard-coded URL unless the project is set up for that.

Do not write E2E tests speculatively. Only write them after the user confirms the feature is done. When a feature implementation appears complete, proactively ask the user (Caveman format):

  • "Feature done? Write E2E?"

Read the full file on GitHub · 57 lines

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. yesterday First seen · 57 lines · 599 tokens per session scan A 6e270c6cf499

Subscribe to this mod's changes

testing is a cursor rule published in the GitHub repository afaraha8403/balakit (1 stars, last pushed 4d ago), licensed MIT. It adds 599 tokens to every session, about $0.0030 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.