agentleFS
extra-orgextra-org/extra/.claude/skills/testing/SKILL.md

testing

Skill113 starsChanged 6 months agoMITView on GitHub

How to write and run fast, deterministic, behavior-focused pytest tests that never touch real external systems. Use whenever adding or changing behavior, or fixing a bug.

123 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use oss-pr, pr-automation and 10 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.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    cicd

    Continuous integration and delivery pipelines

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    networking

    Practical application and coding skills for Networking

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 9 projects that use this

  • Cogni-AI-OUSkill

    dotfiles

    Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.

    Also in 3 projects that use this

  • +2 more from CES-Ltd
  • +1 more from ffsshhttiikk

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 105 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do not edit this file directly.

    line 10
  2. Distinctive:

    No real external systems in unit tests: never call real LLMs, real MCP servers, real databases, or third-party APIs.

    line 41
  3. Distinctive:

    Regression tests for bugs: every fixed bug gets a test that fails before the fix.

    line 46

“Common” is measured: kept by at least 6 in 10 of the 105 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
<!-- This file is generated by tools/skills. Do not edit this file directly. Edit .ai/skills/testing.md and run `make generate-ai`. -->

Skill: Testing

Purpose

Define how to write and run tests for this Python project so that every meaningful behavior is covered by fast, deterministic, behavior-focused tests that never touch real external systems.

When to Use This Skill

  • Adding or changing any behavior (tests accompany behavior — almost always).
  • Fixing a bug (add a regression test first).
  • Working on the test suite or quality gate (task 0012).
  • Reviewing whether a change is adequately tested.

Files to Read First

  • AGENTS.md
  • docs/DEVELOPMENT_WORKFLOW.md
  • pyproject.toml ([tool.pytest.ini_options])
  • The skill for the area under test (runtime, prompts, plugins, tools, etc.).

Core Principles

  • Use pytest. Tests live under tests/, mirroring src/agentplatform/.
  • Test behavior through public interfaces, not private implementation details (test internals only when there is no public seam).
  • No real external systems in unit tests: never call real LLMs, real MCP servers, real databases, or third-party APIs. Mock/fake them.
  • Integration tests only when explicitly requested, and still without real secrets or live third-party calls — use fakes/local stand-ins.
  • Deterministic: control time, randomness, and ordering.
  • Regression tests for bugs: every fixed bug gets a test that fails before the fix.

Process

  1. Pick the category (see below) for what you are testing.
  2. Arrange with fixtures for repeated setup (specs, compiled graphs, fake resolver/access plugins, fake tools). Use @pytest.mark.parametrize for input variations.
  3. Mock external boundaries (LLM/MCP/DB/HTTP) at the adapter seam, not deep inside.
  4. Write behavior assertions: given input, assert observable output/effects.
  5. Cover negatives and security: invalid YAML/validation errors, missing required prompt variables, denied protected-node access, plugin errors.
  6. Run make test (and make check for the full gate). Fix failures.

Testing categories (use the right one)

  • Unit tests — a single function/class via its public interface.
  • Integration tests — multiple layers together (e.g. validate → compile → run) with fakes; only when requested.
  • Contract tests — verify plugin contracts and the YAML schema match docs/; catch drift early.
  • Golden example tests — a known YAML config produces a known compiled graph / rendered prompt; update goldens deliberately.
  • Negative tests — invalid specs, missing variables, denied access must fail clearly with the right error.
  • Security tests — protected access fail-closed, secrets redacted, no request-state leakage.

Example pytest structure (illustrative, not product tests)

import pytest

@pytest.fixture
def valid_spec_dict() -> dict:
    return {"version": "1.0", "app": {"name": "demo"}, "...": "..."}

@pytest.mark.parametrize("missing_key", ["version", "app", "runtime"])
def test_validation_reports_missing_top_level_key(valid_spec_dict, missing_key):
    data = dict(valid_spec_dict)
    del data[missing_key]
    result = validate_spec(data)            # public interface
    assert not result.ok
    assert any(missing_key in e.message for e in result.errors)

Do not implement real product tests in this task. Only trivial repository smoke tests (e.g. import + version) belong here until task 0001+ create code.

Checklist Before Finishing

  • New/changed behavior has tests; bugs have regression tests.
  • Tests target public interfaces and assert behavior, not internals.
  • External systems are mocked/faked; no real LLM/MCP/DB/API calls.
  • Negative and security cases covered where relevant.
  • Tests are deterministic (time/randomness/order controlled).
  • Fixtures/parametrization used to keep tests readable and DRY.
  • make test (and make check) pass, or you state why they can't run.

Common Mistakes to Avoid

  • Calling real LLMs/MCP/DBs/APIs in unit tests.
  • Asserting on private attributes/log strings instead of behavior.
  • Flaky tests depending on real time, randomness, or ordering.
  • Over-mocking until the test asserts nothing meaningful.
  • Skipping negative/security tests because the happy path passes.
  • Committing secrets or production endpoints in fixtures.

Expected Final Report

State: which test files/categories were added or changed; what behaviors and edge/negative/security cases are now covered; mocks/fakes used for external boundaries; the result of make test / make check; and any coverage gaps intentionally left for a later task.

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.