agentleFS
snui1ssnui1s/losna-cli/skills/unit-testing/SKILL.MD

unit-testing

Skill1 starsChanged 2 months agoApache-2.0View on GitHub

2. Match the project's existing test file convention (naming, folder location, assertion style) rather than imposing a default. Look at one existing test file first if any exist. 3. NEVER let tests touch a real database, real files outside a temp directory, or make real network/API calls. Use the language's standard mocking/faking approach: - Python: monkeypatch / unittest.mock, tmp_path fixture - JS/TS: jest.mock() / vi.mock(), a temp dir via fs.mkdtemp - Go: interfaces + fake implementations, t.TempDir() - Java: Mockito,…

20 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use database-testing, contract-testing and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • petrkindlmannSkill

    database-testing

    Validate database integrity, test migrations forward and backward, verify schema constraints, manage seed data, detect migration drift, and identify query performance issues. Covers PostgreSQL, MySQL, MongoDB with Prisma, TypeORM, Drizzle, and SQLAlchemy, plus Testcontainers test databases. Use when: "database test," "migration test," "migration rollback," "rollback test," "data integrity," "SQL test," "schema validation," "seed data," "query performance," "Testcontainers." Not for: synthetic data generation/masking at scale — use test-data-management; Docker/IaC test-environment provisioning — use test-environments; SQL injection — use security-testing. Related: test-data-management, test-environments, security-testing, ci-cd-integration.

    Also in 3 projects that use this

  • petrkindlmannSkill

    contract-testing

    Implement consumer-driven contract testing with Pact-JS (v16). Covers consumer test writing, broker-driven provider verification, Pact Broker setup, can-i-deploy as a deployment gate, webhook-triggered verification, pending pacts, and schema-first vs consumer-first approaches (OpenAPI/Ajv, Schemathesis). Use when: "contract test," "Pact," "consumer-driven," "API contract," "provider verification," "can-i-deploy." Not for: stubbing or mocking a dependency to isolate a test — use service-virtualization; general REST/GraphQL endpoint assertions against your own API — use api-testing. Related: api-testing, service-virtualization, ci-cd-integration, test-environments.

    Also in 3 projects that use this

  • jarosser06Skill

    test-strategy

    Plans pytest test strategies for Drift's 90%+ coverage requirement using coverage analysis, edge case identification, and test suite design. Use when determining what tests to write, analyzing coverage gaps, or planning test strategies.

    Also in 4 projects that use this

  • etewiahSkill

    e2e-testing

    Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.

    Also in 4 projects that use this

  • Microsoft AzureSkill

    release-readiness

    Complete ODIN release documentation and validation checks before declaring user-visible work complete, preparing a release, or opening the Release-to-main pull request.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 4 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before reading any target file to understand what to test, follow the code-navigation skill's rules (get_file_info first, large …

    line 5
  2. Distinctive:

    NEVER let tests touch a real database, real files outside a temp directory, or make real network/API calls.

    line 20
  3. Very specific:

    Every bug that gets found and fixed in this session should get a regression test that would have caught it - not just a fix.

    line 32
  4. Very specific:

    Test the failure path, not just the happy path: what happens when a dependency call throws/errors, when input is null/None/undefined, when …

    line 37
  5. Distinctive:

    Keep tests fast and independent - no sleeps/timers as a substitute for proper synchronization, and no test may depend on another test's …

    line 42
  6. Distinctive:

    When fixing a bug elsewhere in the codebase, add or update its test in the same session - not as a separate follow-up.

    line 46
  7. Distinctive:

    Write the tests and run them once to confirm they at least execute without collection errors.

    line 50
  8. Distinctive:

    Always cleanup testing artifacts (like newly created temp files, local temp databases, or environment variables) after the test runs, …

    line 55
  9. Distinctive:

    Before writing any test, read the target file's own import statements first to know its ACTUAL dependencies.

    line 61
  10. Distinctive:

    When tests fail, fix ONE failure at a time: read only the relevant test + relevant source function (not the whole file via read_local_file …

    line 64
  11. Distinctive:

    Never use shell redirects (2>&1, 2>nul, >, |) with execute_shell_command

    line 69
  12. Distinctive:

    When a test fails, first determine WHICH side is wrong - the test's assumption, or the source code's behavior - before fixing either one.

    line 72
  13. Distinctive:

    Never weaken an assertion just to make it pass without understanding why it failed.

    line 74
  14. Very specific:

    When mocking a third-party library/SDK, only look at HOW the target file uses it (which methods/attributes it calls, in what shape) - do …

    line 76

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “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

Unit Testing Skill

Description: Use this whenever asked to write, run, or fix unit tests for any project, regardless of language (Python, JavaScript/TypeScript, Go, Java, Rust, etc).

Rules for this task

  1. Before reading any target file to understand what to test, follow the code-navigation skill's rules (get_file_info first, large view_file_lines ranges, no repeated list_directory calls). Do not read a file 6 times in 150-line chunks when one get_file_info + 2-3 well-sized reads would do.
  2. Detect the project's language and existing test framework before writing anything. Check for config/lockfiles first: pytest.ini/pyproject.toml -> pytest; package.json -> check for jest/vitest/mocha; go.mod -> Go's built-in testing package; pom.xml/build.gradle -> JUnit; Cargo.toml -> Rust's built-in #[test]. Never introduce a second test framework into a project that already has one.
  3. Match the project's existing test file convention (naming, folder location, assertion style) rather than imposing a default. Look at one existing test file first if any exist.
  4. NEVER let tests touch a real database, real files outside a temp directory, or make real network/API calls. Use the language's standard mocking/faking approach:
    • Python: monkeypatch / unittest.mock, tmp_path fixture
    • JS/TS: jest.mock() / vi.mock(), a temp dir via fs.mkdtemp
    • Go: interfaces + fake implementations, t.TempDir()
    • Java: Mockito, JUnit's @TempDir
    • Rust: trait objects + fakes, tempfile crate A fake must match the real dependency's interface/contract exactly (same method names, same call signature) so it fails loudly if the real interface changes.
  5. Every bug that gets found and fixed in this session should get a regression test that would have caught it - not just a fix. Name the test after the bug's symptom, not generically (e.g. test_archive_does_not_duplicate_on_reload, not test_archive_2).
  6. Test the failure path, not just the happy path: what happens when a dependency call throws/errors, when input is null/None/undefined, when an ID or path doesn't exist, when a boundary value is hit (empty list, max length, zero).
  7. Keep tests fast and independent - no sleeps/timers as a substitute for proper synchronization, and no test may depend on another test's side effects or run order. Every test must pass alone AND in any order.
  8. When fixing a bug elsewhere in the codebase, add or update its test in the same session - not as a separate follow-up. An unfixed bug without a regression test can silently reappear later.
  9. Write the tests and run them once to confirm they at least execute without collection errors. Report the pass/fail count and list any failures with their error messages - but do NOT attempt to fix the source code or the test assertions afterward. Stop here and let the user decide what to do with the failures.
  10. Always cleanup testing artifacts (like newly created temp files, local temp databases, or environment variables) after the test runs, ensuring no leftover garbage files in the project workspace.
  11. Stay scoped to the target file only. Do not read sibling files (config, init, other modules) unless the target file's imports require understanding them. If unsure whether pytest/test deps are installed, check pyproject.toml/requirements.txt ONCE at the very start, before reading any other file.
  12. Before writing any test, read the target file's own import statements first to know its ACTUAL dependencies. Never guess or add unrelated packages (e.g. requests, pandas) that the target file doesn't import.
  13. When tests fail, fix ONE failure at a time: read only the relevant test + relevant source function (not the whole file via read_local_file or sub-agent), make the fix, re-run only that test file, then move to the next failure. Do not scatter-search multiple failing test names at once with search_in_files.
  14. Never use shell redirects (2>&1, 2>nul, >, |) with execute_shell_command
    • it runs with shell=False and redirects will not work; the tool already returns both stdout and stderr separately.
  15. When a test fails, first determine WHICH side is wrong - the test's assumption, or the source code's behavior - before fixing either one. Never weaken an assertion just to make it pass without understanding why it failed. State explicitly which side you're fixing and why.
  16. When mocking a third-party library/SDK, only look at HOW the target file uses it (which methods/attributes it calls, in what shape) - do not read the library's own source code in .venv/site-packages, node_modules, or vendor directories to "verify" the interface. Match only the exact call pattern found in the target file being tested.

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.