agentleFS
wtsi-hgiwtsi-hgi/agentskills/skills/testing-principles/SKILL.md

testing-principles

Skill1 starsChanged 39 days agoMITView on GitHub

Shared guidance for behaviour-focused tests in TDD, regression fixes, acceptance-test implementation, perceptual and visual requirements, property and generated-input coverage, flaky test fixes, and test review. Use when writing, updating, stabilizing, or reviewing tests, or briefing another agent about tests, especially when deciding whether a cleanup/removal request needs a new test.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 11 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use tests to declare desired behaviour and prove the system has that behaviour.

    line 10
  2. Distinctive:

    When the requirement is perceptual (colour, contrast, spacing, a focus ring, a selection state, an animation end state), the supported …

    line 17
  3. Distinctive:

    Before completing a user-visible behaviour change, prove the affected paths through the real app's supported interface.

    line 29
  4. Distinctive:

    Follow verification for discovery, execution, evidence, and failure handling.

    line 34
  5. Distinctive:

    Do not write tests whose only claim is an implementation detail: private helpers, source layout, filenames, imports, CSS classes, deleted …

    line 40
  6. Distinctive:

    Do not test a dependency's behaviour (that belongs in its project), test-only helpers, or language features.

    line 45
  7. Distinctive:

    Keep the generator deterministic, seeded from a fixed value, so a failure reproduces.

    line 71
  8. Distinctive:

    Treat a flaky test as a bug in the test suite or product, not as a reason to skip coverage.

    line 77
  9. Distinctive:

    If a user asks to remove obsolete implementation or get rid of a previously implemented feature, first identify the desired behaviour after …

    line 88
  10. Distinctive:

    If supported behaviour changes, write a failing test for the new desired behaviour.

    line 91
  11. Distinctive:

    If supported behaviour does not change, do not invent a new test that asserts old artifacts are gone.

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing Principles

Core Rule

Use tests to declare desired behaviour and prove the system has that behaviour. Prefer supported boundaries: public APIs, CLI output, HTTP contracts, rendered UI, persisted state, emitted files, errors, or other effects visible to users, callers, or downstream steps.

Perceptual Requirements

When the requirement is perceptual (colour, contrast, spacing, a focus ring, a selection state, an animation end state), the supported boundary is the rendered result in a real browser. Source CSS, class names, and jsdom computed styles do not prove it.

Assert on a screenshot, or on sampled pixels and measured geometry, through the same theming mechanism production uses. Compare the element against its own fill and nearby surfaces rather than against token names. This holds for a test, for a review, and for a bug's red command alike.

User-Path Verification

Before completing a user-visible behaviour change, prove the affected paths through the real app's supported interface. Existing E2E tests count when they exercise those paths and assert the required outcomes. Keep targeted regression tests; run the full suite when project policy or change scope requires it.

Follow verification for discovery, execution, evidence, and failure handling. After later edits or rebases, refresh affected proof before completion or publication.

Avoid

Do not write tests whose only claim is an implementation detail: private helpers, source layout, filenames, imports, CSS classes, deleted files, removed functions, removed routes, removed modules/processes, or the mere absence of an old feature.

Do not test a dependency's behaviour (that belongs in its project), test-only helpers, or language features. Give every test synchronisation aid (sleep, channel, hook, wrapper) an evident purpose, and derive each wait's bound from what it waits on, never a guess.

Properties and Generated Input

A worked example the spec names earns a table test. A claim that must hold across a whole domain earns generated input as well: overflow safety over a numeric range, a round-trip that must return the original, a parser that must never panic on any input.

Name the property before generating anything. Four shapes carry most cases:

  • Oracle. A slower obviously-correct version agrees with the fast one.
  • Round-trip. Decoding an encoded value returns the input.
  • Invariant. Output stays in range, a total is conserved, nothing panics.
  • Two paths agree. A cached or optimised path matches the plain one.

Assert the property, never a second copy of the implementation. Generated input that recomputes the code the same way proves only self-consistency.

Generated input supplements the spec's worked examples and never replaces them. A named example is a requirement; a generator that happens to reach it today may not tomorrow.

Keep the generator deterministic, seeded from a fixed value, so a failure reproduces. A failing generated case is a finding, not flakiness: pin that exact input as a permanent regression case, then fix the code.

Flaky Tests

Treat a flaky test as a bug in the test suite or product, not as a reason to skip coverage. Do not skip, quarantine, xfail, delete, or loosen the test until it no longer proves behaviour.

You may reimplement a flaky test to make it deterministic when the replacement preserves the spirit of what the original test was trying to prove. Prefer stable user-visible boundaries and remove nondeterminism by controlling clocks, randomness, ordering, external services, async waits, or fixture setup.

Cleanup and Removal

If a user asks to remove obsolete implementation or get rid of a previously implemented feature, first identify the desired behaviour after the change.

  • If supported behaviour changes, write a failing test for the new desired behaviour.
  • If supported behaviour does not change, do not invent a new test that asserts old artifacts are gone. State why no new test is appropriate, then run the existing behavioural tests and quality gates.

Review Rule

Reject tests that pass by coupling to implementation details, hardcoded results, stubs that bypass the behaviour under test, or assertions that only prove old artifacts are absent. Accept a cleanup/removal with no new test only when the implementor explicitly justifies that no supported behaviour changed and the existing behavioural tests and quality gates pass. Reject flaky-test changes that merely skip, quarantine, delete, or weaken the check instead of preserving its behavioural intent. Reject generated-input tests whose assertion re-implements the code under test, and reject a generated failure that is silenced or re-seeded away instead of pinned as a regression case.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.