Skip to content
Agentmart
Submit a tool

writing-tests

Use when writing tests, changing tests, or implementing code that needs tests.

Skill by utilitydelta

IndexedMIT★ 2
Write a review

Chalk Labs

Need help deploying writing-tests?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/utilitydelta-writing-tests

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when writing tests, changing tests, or implementing code that needs tests. Which test layer to pick (unit, integration, DST, chaos), how to write unit tests, when to mock, and when to use property tests, fuzzing, or mutation testing.

Use cases: testing, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/writing-tests

What's inside

Skill name
writing-tests
Description
Use when writing tests, changing tests, or implementing code that needs tests. Which test layer to pick (unit, integration, DST, chaos), how to write unit tests, when to mock, and when to use property tests, fuzzing, or mutation testing.
License
MIT
Instructions
79 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Writing Tests

You already know how to test. This is the order, the defaults, and the bans.

## Pick the cheapest layer that catches the failure

1. **Unit** - pure logic, branches, boundaries. In-process, microseconds.
2. **Integration** - real components wired together on one machine. Real I/O, config, startup. Runs a real binary.
3. **DST** (deterministic simulation testing) - simulated clock, disk, network. Seeded scheduler, exact replay from seed. Catches concurrency and failure-ordering bugs. Only for systems built on a simulation substrate from day one; retrofitting is a rebuild.
4. **Chaos** - real machines, real network, failure injection. Split-brain, partitions, kernel stalls, SIGKILL, high load. DST does not replace chaos: a fault model only finds failures someone thought to model.

Prefer unit while building. Push a test up a layer only when the cheaper layer cannot express the failure.

A unit test needing several mocks is an integration test. Move it.

External dependencies: OSS substitute in docker on the local box. If the substitute lies about the real platform's behaviour, use a cloud non-prod environment.

## Unit test rules

- Cases that differ only in data are one parameterized test with a table, not many near-copies. The failure message must name the row.
- Separate tests only when cases differ in structure, not values.
- Exercise the contract through a shared helper, so a contract change means one place to update. Never assert on private state.
- Name the invariant, not the method. "rejects an expired token", not "test login works".
- Assert the failure path too: which input fails, with which error.

## Mocking

Mocking is a smell: the code is wired too tightly to its dependencies. In order:

1. Redesign so the dependency is out of the way - a seam, an injected service, a pure function. Usually the right answer.
2. Hand-build a small intentional fake.
3. Mocking frameworks last.

If proving it needs the real collaborators, it is an integration test.

## Generated inputs

Not a fifth layer. These run inside the layers above.

- **Property tests** - when the invariant holds over a whole domain, not a list of cases. State the law, let the generator write the rows. Commit the regression files and seeds so found counterexamples become permanent cases.
- **Fuzzing** - every surface that parses untrusted input. Fixed time budget during a build; continuous fuzzing belongs in CI.
- **Mutation testing** - grades the tests, not the code. Scope it to the current diff and the cheap layers, unit and fast integration.

## UI and e2e

- No screenshot-reading LLM as a gate. Every UI check is deterministic or human.
- Assert what the user sees. Dev hooks are for setup and state reads; a `window.__` read inside an assertion is banned.
- End each e2e test by asserting the expected event sequence. The DOM can look right while the wiring is broken.
- One state rendered in two places: assert the id sets match across the views. Unit tests on each side stay green while the views disagree.
- Overlays get geometry checks from `getBoundingClientRect`: width above a floor, inside the viewport, no page overflow.
- Screenshots are byte diffs against a human-approved baseline. Skip them where baseline churn costs more than it catches.
- Quarantine flaky tests and flag them for human triage. Most flakes are test-side timing; the human decides which are product bugs.

## Defect reproduction

A common failure is an agent writing a red unit test and leaving it at that layer.
At times, unit tests can be synthetic.  Too much mocking or exercise a branch of code that never runs in reality.
Different layers provide different benefits, write failing tests at integration and chaos/higher layers.

live running real instances with scraped metrics and traces, showing the reproduction of the incident  beats an artificial reproduction every time.

Defects can be complex and multi-layered. Establish the causal chain before fixing the downstream one.

- Do not assume the test harness is correct.
- Avoid using proxies to measure correctness.
- 

Common failure modes observed in agent led test writing include:
- Bugs in the harness itself. Trust nothing.
- using a proxy measure instead of a more direct measure to assert failure or correctness.
- After the fix, a green test doesn't mean every edge case is covered.  Mutate and check for failure.

## Order

Write the test first and watch it fail. A test that was never red proves nothing.

Document how to run each suite. A test nobody can run does not exist.

From utilitydelta/build-method, MIT.

More from utilitydelta/build-method

Signals

Stars
2
Forks
0
Open issues
0
Last commit (this folder)
Aug 21, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from utilitydelta

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get writing-tests running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying writing-tests?

CallGet help
Cite this page

writing-tests skill. Agent Mart. https://agentmart.dev/skills/utilitydelta-writing-tests (last updated 2026-10-24)