writing-tests

Installation
SKILL.md

Writing tests

Default = no new test. Every test costs CI time on every run, agent tokens on every change, and friction on every refactor, forever. It earns that cost only by catching a regression that matters and that nothing else would catch. A correct, well-written test can still be a net loss.

Existing tests are not a style reference. Suites written by coding agents tend to test every change and copy the shape of neighbor files; copying a nearby test is how low-value patterns spread. Judge a test by its assertions and the code it runs, never by its title.

Value bar

First ask what a failure would mean: a mistake, or a decision. A test whose expected values are copied from the code (the class list, the SQL text, the mapping table, the order of calls) can only fail when someone changes that code on purpose, and the fix is always the same edit in the test. It catches no mistake, whatever it asserts. A test whose expected values come from the requirement (the price for this cart, the tenant that must not see this row) fails when the code gets the rule wrong.

Then, a test may exist only if at least 3 of these 4 hold:

# Question Yes when
1 Costly if broken? Money, credits, billing, payment or subscription state, tenant/owner isolation, auth/permissions, data loss or integrity, messages sent to customers, external contracts (webhooks, public API, persisted enums, file formats), migrations, security sanitizing. Judge the behavior the test guards, not the size of its assertion: a status, default or guard in billing, credits or customer sends is costly even when the test is three lines.
2 Silent if broken? Types, other tests that already run through this code, and normal use would NOT reveal the break quickly. Anything a user or developer sees on screen while using the feature (layout, styles, labels, a click that does nothing, a wrong date or color) is NOT silent.
3 Likely to break? Non-trivial logic (branches, concurrency, time zones, parsing, state machines), code that changes often, or a past bug.
4 Cheap for what it protects? Fast, small setup, no app boot or login per case, few lines relative to the code it guards.
Installs
3
GitHub Stars
2
First Seen
4 days ago