agentleFS
TacuchiTacuchi/agent-skills/skills/engineering/software-testing/SKILL.md

software-testing

Skill0 starsChanged 2 months agoMITView on GitHub

Use whenever tests are in play — writing, adding, naming, structuring, or running them, or deciding how to verify a change — in any stack, even when the user only says 'add tests' without details, and keep it in force across the session. Picks the level (unit/integration/e2e), resolves the configured runner and command from the detected stack (Maven/Gradle/Angular/Node — committed wrapper or package script, never plain mvn), guides naming and structure ([method]_[scenario]_[result], AAA, TestBuilder), and requires a regression test for every bugfix (red before, green after). Always asks before running a test runner — never launches it without explicit confirmation. Low or absent coverage is a gap to remediate, never a pattern to copy (no skipTests=true, no contextLoads-only). Optional complements, if available: the `coding-standards` skill (and the `java-spring-standards` skill or the `angular-standards` skill) for authoring the code under test; the `git-conventions` skill for commit conventions.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run this once, when the skill loads and before its other steps.

    line 10
  2. Very specific:

    Run node <skill dir>/scripts/permissions.mjs check --root <session folder> --host <claude|codex|agy>.

    line 12
  3. Very specific:

    If node is missing or the command fails, say so, list the needs in <skill dir>/permissions.json and go on with the skill.

    line 13
  4. Very specific:

    Read hosts.<host> in the output.

    line 14
  5. Very specific:

    Run the command of the option the person chose, exactly as given.

    line 16
  6. Distinctive:

    After "Skip for now", do not run this step again in the session.

    line 18
  7. Distinctive:

    Write the test that fails with the current code (red) — it proves the bug exists.

    line 45
  8. Very specific:

    Fixtures age and flatter: use dates relative to now or an injected clock, cross numeric widths (999 against 1000) when testing an order, …

    line 62
  9. Very specific:

    Never propose or leave <skipTests>true</skipTests>.

    line 84
  10. Very specific:

    Never treat a lone contextLoads() as coverage — it is boot smoke, not logic testing.

    line 85
  11. Distinctive:

    When touching a repo without tests, treat it as debt to remediate in what you modify — never as a license to skip.

    line 95
  12. Distinctive:

    If the manifest has no runnable command for the requested level, report the missing configuration.

    line 166
  13. Very specific:

    Run the resolved command per stack and level.

    line 237
  14. Distinctive:

    If the human already validated manually, do not repeat.

    line 239

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

software-testing — Test strategy and execution

Step 0 — Permissions this skill uses

Run this once, when the skill loads and before its other steps. It keeps the session from stopping on a prompt for a command this skill is known to run. It is not a security check: the host and its hooks still decide.

  1. Run node <skill dir>/scripts/permissions.mjs check --root <session folder> --host <claude|codex|agy>. <skill dir> is the folder of this SKILL.md; <session folder> is the folder where the session started; the host is the one you run in.
  2. If node is missing or the command fails, say so, list the needs in <skill dir>/permissions.json and go on with the skill.
  3. Read hosts.<host> in the output. Show its notice when there is one.
  4. Ask each entry of its questions with the host's structured question tool, in the person's language: its text, then its options in the given order, the one marked recommended first. Low-risk and high-risk needs are separate questions; ask them separately and never recommend allowing a high-risk need.
  5. Run the command of the option the person chose, exactly as given. An option without a command writes nothing. Write nothing the person did not choose.
  6. Tell the person the applies line of the result: whether the change works now or after a restart. If the command fails, say so and go on.
  7. After "Skip for now", do not run this step again in the session.

Purpose

Reason about tests: which level to apply, with which command, with which naming/structure convention. It never runs tests autonomously — it first asks the human whether to run them, whether they will run them manually, or whether none are needed.

This skill covers how to test. If available, the style of the code under test can come from the coding-standards skill (+ the java-spring-standards skill / the angular-standards skill), and commits from the git-conventions skill.

Knowledge

Execution rule

By default, never run tests automatically. Before launching any test runner, ask the human, with the host's structured question tool if it has one; otherwise with a numbered markdown list.

Run the tests?
  [a] Yes, run them now
  [b] I will run them manually
  [c] Not needed

Skip the question only if the user already asked to run them, or in a validation step the user explicitly requested.

Verification-first (bugfix => regression test)

A bugfix requires a regression test that reproduces the defect:

  1. Write the test that fails with the current code (red) — it proves the bug exists.
  2. Apply the fix.
  3. The same test now passes (green).

Without the prior red there is no guarantee the test covers the bug. For new features, the test accompanies the new logic — never deferred.

Reproduce before fixing: choose the fix from a reproduction, never from a hypothesis that merely sounds right.

Make the test bite

A green suite proves little until a broken version turns it red.

  • Mutate the guarantee. For each guarantee a change adds, break the code on purpose (restore the defect, delete the guard) and run the test: it must fail. A surviving mutant means the test asserts less than the code promises, usually a final state that the broken version also reaches. Restore from a backup copy of the file; git checkout -- <file> would also discard your uncommitted work.
  • Test the caller, not only the primitive. A correct function that nothing calls is dead, and a harness that supplies the missing wiring by hand is a structural false green. Run the real entry point (the built binary, the HTTP route) at least once and find who consumes each new function.
  • A double is never more permissive than the real thing. Give the fake the invariants of the service it replaces, and keep at least one contract test against the real service or its real validation. Mocks on both sides of a boundary leave a broken contract green on both.
  • An exception added so a check passes is as suspect as a deleted test. Ask which mutation would stay green with it.
  • Guard against vacuous passes: a scan that found zero elements, a scenario another rule already excludes, a catch that turns a crash into data. Assert a floor (at least one item checked) and write one case that varies only what each guard protects.
  • Fixtures age and flatter: use dates relative to now or an injected clock, cross numeric widths (999 against 1000) when testing an order, and use realistic names instead of one/two.

A red you did not cause still has to be proven

A failing test in a repo you just touched is not preexisting because it looks unrelated. Demonstrate it: run the same command against the untouched base — another checkout of the same commit, or a clean worktree — and compare the failure, by name, not by count. An equal count with different names hides a new regression behind an old one.

git stash is the wrong instrument for this. It mutates the tree you are measuring, and on a clone shared with other worktrees or other agent sessions the stash stack is shared too, so a pop can take somebody else's work. Prefer a second checkout.

Report a preexisting failure with its evidence — the command, the environment, the cause — and never as an aside. "It was already broken" without that is indistinguishable from not having looked.

Coverage is a GAP, not a convention

In many codebases testing is nearly absent: a repository has only a @SpringBootTest contextLoads() (or no src/test at all), a pom.xml carries maven-surefire-plugin with <skipTests>true</skipTests> so declared tests never run, a frontend has a handful of specs, or a static-analysis gate stands in for a suite.

Never emulate this anti-pattern. Rules:

  • Never propose or leave <skipTests>true</skipTests>.
  • Never treat a lone contextLoads() as coverage — it is boot smoke, not logic testing.
  • Empty stub tests (a @Test method with a blank body) do not count; either complete them or do not add them.
// ANTI-PATTERN: a repository whose only real tests
// leave two cases as empty shells — do NOT replicate.
@Test public void testActive_CronNotFound() { }   // no Arrange/Act/Assert
@Test public void testActive_CronInactive()  { }

When touching a repo without tests, treat it as debt to remediate in what you modify — never as a license to skip.

Test levels

Three universal levels, adapted to the detected stack:

LevelScopeWhen
a) UnitIsolated logic (services, utils, mappers) with mocked dependenciesTargeted fix, logic without external dependencies
b) IntegrationUnit + API/controller layerNew or modified endpoint
c) Full / e2eIntegration + full contextComplete feature, critical cross-layer flow

Stack resolution

Detect the stack, test engine, runner version and command from the repository's manifests, build files, wrapper, package-manager declaration and test configuration. Those declarations are the current compatibility baseline; never add or upgrade a runner merely because it appears in an example below. For a new project or explicit runner/toolchain migration, use the version-evolution skill if it is available, and select a supported release compatible with the chosen language/framework baseline.

Never use global mvn/gradle — always the committed wrapper. If an existing repository lacks one, report that reproducibility gap. A new project must generate, pin and commit its wrapper before the first verification command.

Spring Boot (Maven)

LevelTypical scopeCommand
a) Unitconfigured Java test engine + mocking library./mvnw test -Dtest=ClassTest
b) Integrationconfigured controller/API test support./mvnw test
c) Fullconfigured full-context/integration suites./mvnw verify

Windows: mvnw.cmd instead of ./mvnw.

Spring Boot (Gradle)

LevelCommand
a) Unit./gradlew <declared-unit-task> --tests ClassTest when that task supports filtering
b) Integration./gradlew <declared-integration-task>
c) Full./gradlew <declared-verification-task>

Resolve the placeholders from tasks registered by the target build. test, integrationTest and check are common examples, not guaranteed task names.

Angular

LevelTypical scopeCommand
a) Unitconfigured Angular unit runnerthe repository's test script with its supported non-watch flag
b) Integrationconfigured Angular component test supportthe repository's test script with its supported non-watch flag
c) Fullconfigured browser/e2e runner, if presentthe repository's e2e script

Karma/Jasmine, Jest, Vitest, Cypress and Playwright are examples found in different generations, not defaults to install. Use only the runner and flags supported by the selected Angular builder.

Generic Node / TypeScript

LevelCommand
a) Unitthe declared package manager's test script
b) Integrationits configured integration script/suite
c) Fullits configured e2e script

Automatic resolution

  1. mvnw / mvnw.cmd → Maven wrapper and the project's configured test plugins.
  2. gradlew / gradlew.bat → Gradle wrapper and declared test tasks.
  3. package.json → honor packageManager, lockfile and scripts; use the declared package manager.
  4. angular.json → inspect its test/e2e builders when scripts delegate to the Angular CLI.

If the manifest has no runnable command for the requested level, report the missing configuration; do not silently substitute a globally installed tool or introduce a historical runner.

Naming conventions

Java: class [Target]Test.java, method [method]_[scenario]_[result]. Arrange-Act-Assert structure. @Mock for collaborators, @InjectMocks for the SUT.

@Test
void active_cronInactive_throwsException() {
    // Arrange
    var parameter = new ParameterDTO(/* ... inactive status ... */);
    when(parameterService.findByAppCode(APP, PRM_CRON))
            .thenReturn(parameter);
    // Act + Assert
    assertThrows(BusinessException.class,
            () -> validateCronService.active(PRM_CRON));
}

Note: existing code may use ad-hoc names (testActive_CronActive); prefer the [method]_[scenario]_[result] pattern for new cases.

Angular / TypeScript: file [name].spec.ts, describe / it blocks. TestBed for components; it messages describe the behavior, not the implementation.

describe('AuthService', () => {
  it('should return a token on login', () => {
    // Arrange / Act / Assert
  });
});

TestBuilder pattern (Java)

Build reusable fixtures without coupling tests to the production constructor. Useful with entities/DTOs that carry audit or status fields:

public class RequestTestBuilder {
    private Integer status = 1;           // 1 = active (soft status)
    private String document = "12345678";

    public static RequestTestBuilder builder() { return new RequestTestBuilder(); }

    public RequestTestBuilder document(String v) { this.document = v; return this; }
    public RequestTestBuilder status(Integer v)  { this.status = v;   return this; }

    public Request build() {
        var r = new Request();
        r.setDocument(document);
        r.setStatus(status);
        return r;
    }
}

Level selection prompt (shown to the human, in the user's language)

Adapt to the resolved stack. Spring Boot example:

Which test level do we apply?
  a) Unit        — configured runner and mocks (fast, isolated)
  b) Integration — configured API/controller support
  c) Full        — configured context/integration suites

The human can switch levels at any time or decide not to run.

Execution and logging

  1. Confirm the human wants execution (see "Execution rule").
  2. Run the resolved command per stack and level. Read the runner's own exit code: in <runner> | tail; echo $? the code is tail's, so use ${PIPESTATUS[0]} or redirect the output to a log.
  3. On failures, if the human wants to continue: fix and re-run.
  4. If the human already validated manually, do not repeat; note one brief line if it adds traceability.

Output

It produces no artifacts autonomously. When the human confirms execution:

  • Runs the resolved command and reports the result inline.
  • Writes a brief test log only when explicitly requested.
  • For a bugfix, records the added regression test (red→green).

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.