writing-tests

Guides writing, fixing, and reviewing tests that verify real behavior instead of source text.

64|11|Updated May 24, 2026
One-click install
npx skills add https://github.com/AlexanderMattTurner/agent-glovebox --skill writing-tests-alexandermattturner
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-tests
Source: https://github.com/AlexanderMattTurner/agent-glovebox/tree/main/.claude/skills/writing-tests
Command: npx skills add https://github.com/AlexanderMattTurner/agent-glovebox --skill writing-tests-alexandermattturner

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Test suites often pass while hiding real defects: tests grep source text instead of driving behavior, stub the very component they claim to exercise, assert constants against their own literals, or silently go green over empty input lists. This Skill encodes the rules that make a test actually capable of failing when a defect returns. ## Core Features & Use Cases - Behavior-over-text testing: Drive the real code path and assert observable outcomes (files written, argv passed, exit codes) instead of grepping implementation source. - Non-vacuity proof: Require red-on-old, green-on-new verification for bug-fix tests, plus mutation-based checks for new logic. - Stub discipline: Fake the remote service, never the local tool; use recorded, scrubbed fixtures when the real dependency genuinely cannot run. - Use Case: When asked to add a regression test for a bug fix, the Skill directs you to revert the fix, watch the test go red for the bug's signature, restore the fix, and confirm green before committing. ## Quick Start Ask the AI to write a regression test for the bug you just fixed, following the repo's testing rules.

Frequently Asked Questions about writing-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a regression test that actually catches the bug?

Write the test, then revert the fix and confirm the test goes red for the bug's signature rather than a setup error, then restore the fix and confirm green. State this red-on-old, green-on-new proof when reporting the change.

Why is grepping source code in a test considered bad practice?

A text search passes whether or not the matched line ever executes, breaks on harmless renames, and stays green against broken implementations containing the token. Drive the real code path and assert observable outcomes like files written, exit codes, or argv passed.

When is it acceptable to use a stub in tests?

Stubs are licensed only when the real dependency genuinely cannot run, such as paid APIs or missing hardware capabilities. Feed the stub a recorded, scrubbed response captured from the real dependency, and document why the real thing could not run.

How do I test code that verifies signatures or checksums?

A test serving only agreeing input proves nothing, since it stays green after the verification is deleted. Drive the refusing direction too and assert what did not happen, such as the binary never reaching PATH.

Why does my parametrized test pass when it finds no cases?

A parametrize over an empty sequence collects zero cases and reports a clean pass. Assert the input list is non-empty at the single point that reads it, so a broken helper cannot silently turn every dependent test green.

How should I pin a known defect I cannot fix yet?

Assert the correct behavior and mark the test with pytest xfail using strict=True and a reason naming where the fix lives. Strict mode turns the eventual fix into an XPASS failure until the marker is removed.