OSS Tests
Create the minimum automated test loop that materially protects the repository. Bias toward deterministic tests that run in CI without secrets.
Context: $ARGUMENTS
Input Contract
- Primary input: current codebase plus
OSS_AUDIT.md or OSS_PLAN.md if available.
- Optional input: critical workflows, known failure modes, or target command such as
python app.py.
- Default: focus on the main user-facing path and the top audit risks.
Output Contract
Produce:
- Actual test files or test scaffolding where feasible.
OSS_TEST_STRATEGY.md containing:
- chosen test framework and why
- test command(s)
- mock/fake strategy for external dependencies
- known gaps
- At least three classes of test coverage:
- critical path
- failure branch
- input validation
The strategy file must include a table like:
| Test class | Target | Why it matters | CI notes |
|------------|--------|----------------|----------|
| Critical path | `src/cli.py` happy path | protects the main user workflow | no network, fixture input |
| Failure branch | missing file / bad config | proves clear failure behavior | assert exit code and stderr |
| Input validation | invalid arguments | blocks unsafe or confusing inputs | pure unit test |
Non-goals
- Do not chase high line coverage for its own sake.
- Do not add tests that require secrets, paid APIs, or live infrastructure.
- Do not lock the repo into a heavyweight test stack unless the repo already uses it.
Strategy Rules
- Prefer built-in or already-present frameworks first.
- Add fixtures, fakes, or dependency injection seams before adding slow integration tests.
- If external services exist, replace them with mocks, temporary files, or recorded responses.
- If the code is too entangled to test directly, do the smallest seam extraction necessary and document it.
- For paper or benchmark code, prefer a smoke test on a tiny fixture or toy config over full training or evaluation runs.
- Capture fixed seeds, expected exit codes, or lightweight artifact-shape assertions when determinism matters.
Workflow
Step 1: Pick the smallest reliable test command
Examples:
- Python:
python -m unittest or existing pytest command
- Node: existing
npm test or node --test
- Go:
go test ./...
- Rust:
cargo test
Step 2: Choose three high-value cases
Start with:
- Critical path success case
- Failure branch with a clear user-visible error
- Input validation or boundary handling
Only add more once those are stable.
For paper code, the "critical path" is often the smallest reproducible run: load a tiny fixture, execute one representative step, and assert the expected output shape or file exists.
Step 3: Make tests CI-safe
- No network calls
- No secrets
- No reliance on local machine state
- No long-running jobs
Step 4: Run and record
- Run the chosen test command locally.
- Record the command and outcome in
OSS_TEST_STRATEGY.md.
Anti-patterns
- Do not optimize for coverage numbers instead of protecting the critical path.
- Do not add tests that need secrets, network access, paid APIs, or large private assets.
- Do not keep flaky tests in the default CI loop; either fix or explicitly exclude them.
- Do not invent test coverage claims that cannot be verified locally.
Self-check
Before declaring this stage complete, verify:
Failure Handling
- If the repo has no testable seam yet, document the blocker and add the smallest seam extraction task.
- If a test is flaky, either stabilize it immediately or leave it out and note the reason.
- If the best available test is only a smoke test, say so explicitly and list the missing deeper tests.
Done Criteria
OSS_TEST_STRATEGY.md exists and records the chosen framework, exact local test command, mock/fake strategy, known gaps, and coverage table.
- The repo contains test files or scaffold files for the chosen test path.
- The test loop is CI-safe or the blocker preventing that is explicitly recorded.
1---2name: oss-tests3description: Build the smallest effective automated test loop for a repository. Use when the user says "add tests", "make this CI-safe", "cover the important paths", or wants a minimal but meaningful test strategy with mocks instead of secrets or live services for either product code or research code.4---56# OSS Tests78Create the minimum automated test loop that materially protects the repository. Bias toward deterministic tests that run in CI without secrets.910## Context: $ARGUMENTS1112## Input Contract1314- Primary input: current codebase plus `OSS_AUDIT.md` or `OSS_PLAN.md` if available.15- Optional input: critical workflows, known failure modes, or target command such as `python app.py`.16- Default: focus on the main user-facing path and the top audit risks.1718## Output Contract1920Produce:21221. Actual test files or test scaffolding where feasible.232. `OSS_TEST_STRATEGY.md` containing:24 - chosen test framework and why25 - test command(s)26 - mock/fake strategy for external dependencies27 - known gaps283. At least three classes of test coverage:29 - critical path30 - failure branch31 - input validation3233The strategy file must include a table like:3435```markdown36| Test class | Target | Why it matters | CI notes |37|------------|--------|----------------|----------|38| Critical path | `src/cli.py` happy path | protects the main user workflow | no network, fixture input |39| Failure branch | missing file / bad config | proves clear failure behavior | assert exit code and stderr |40| Input validation | invalid arguments | blocks unsafe or confusing inputs | pure unit test |41```4243## Non-goals4445- Do not chase high line coverage for its own sake.46- Do not add tests that require secrets, paid APIs, or live infrastructure.47- Do not lock the repo into a heavyweight test stack unless the repo already uses it.4849## Strategy Rules5051- Prefer built-in or already-present frameworks first.52- Add fixtures, fakes, or dependency injection seams before adding slow integration tests.53- If external services exist, replace them with mocks, temporary files, or recorded responses.54- If the code is too entangled to test directly, do the smallest seam extraction necessary and document it.55- For paper or benchmark code, prefer a smoke test on a tiny fixture or toy config over full training or evaluation runs.56- Capture fixed seeds, expected exit codes, or lightweight artifact-shape assertions when determinism matters.5758## Workflow5960### Step 1: Pick the smallest reliable test command6162Examples:6364- Python: `python -m unittest` or existing `pytest` command65- Node: existing `npm test` or `node --test`66- Go: `go test ./...`67- Rust: `cargo test`6869### Step 2: Choose three high-value cases7071Start with:72731. Critical path success case742. Failure branch with a clear user-visible error753. Input validation or boundary handling7677Only add more once those are stable.7879For paper code, the "critical path" is often the smallest reproducible run: load a tiny fixture, execute one representative step, and assert the expected output shape or file exists.8081### Step 3: Make tests CI-safe8283- No network calls84- No secrets85- No reliance on local machine state86- No long-running jobs8788### Step 4: Run and record8990- Run the chosen test command locally.91- Record the command and outcome in `OSS_TEST_STRATEGY.md`.9293## Anti-patterns9495- Do not optimize for coverage numbers instead of protecting the critical path.96- Do not add tests that need secrets, network access, paid APIs, or large private assets.97- Do not keep flaky tests in the default CI loop; either fix or explicitly exclude them.98- Do not invent test coverage claims that cannot be verified locally.99100## Self-check101102Before declaring this stage complete, verify:103104- [ ] `OSS_TEST_STRATEGY.md` exists and names the framework, test command, mock/fake strategy, and known gaps.105- [ ] It includes a coverage table for: critical path, failure branch, and input validation (or records blockers for missing classes).106- [ ] Actual test files or explicit scaffold targets were added.107- [ ] The chosen test command is recorded as CI-safe, or the blocker is stated clearly.108109## Failure Handling110111- If the repo has no testable seam yet, document the blocker and add the smallest seam extraction task.112- If a test is flaky, either stabilize it immediately or leave it out and note the reason.113- If the best available test is only a smoke test, say so explicitly and list the missing deeper tests.114115## Done Criteria116117- `OSS_TEST_STRATEGY.md` exists and records the chosen framework, exact local test command, mock/fake strategy, known gaps, and coverage table.118- The repo contains test files or scaffold files for the chosen test path.119- The test loop is CI-safe or the blocker preventing that is explicitly recorded.