- How you use it
- You ask for it
- What it can do
- installs software · writes files
- What's inside
The option
| Option | ASkill · v1.0.0+wwfix.1python-testing-patterns skill (wshobson/agents) |
|---|---|
| How you use it | You ask for it |
| What it can do | installs software · writes files |
| What's inside |
What this thread does
The problem
The agent writes unit tests where the database, services and helpers are all mocked. They pass, but they only check that the mocks were called, and the code breaks at the real boundary. It also invents new fixture helpers instead of using yours.
What the guides say
- A pytest guide (claudify.tech, 12 May 2026) says Claude reaches for mocks when it is uncertain about dependencies. Rules it recommends for
CLAUDE.md: never mock the thing under test, mock only its dependencies; use a real in-memory database with a function-scoped session that rolls back after each test (Postgres only when you need Postgres features); put only session-scoped fixtures in the rootconftest.py; use factory fixtures that return a callable so each test sets only the fields it cares about. - A testing lesson at developertoolkit.ai (by Michal Jaskolski, updated 21 November 2026, link) says over-mocked suites pass because they never touch the boundary where production fails, to mock only true external edges, and to add a contract test against the provider's sandbox if a mock and the real API can drift. It tells the agent to read two existing test files and list their conventions, and for "tests pass alone and fail together" to eliminate shared mutable fixtures, reset mocks in
beforeEachand wrap database tests in a rolled-back transaction. - A PHP review (mironsoft.de, April 2025) adds that mocked repositories often return only the success case, leaving error paths untested.
Prompt and rules to try
"Before writing tests, read the existing tests and the fixtures folder and reuse them. Use the real test database with a rollback per test. Mock only network calls and clocks. For every mock, add an assertion on the behavior, not just on the call."
Check the result
Run mutation testing on the changed files (see the existing mutation-testing thread): heavily mocked tests usually let mutants survive.
Limits
Practitioner blogs; no study compares mock-heavy and real-database tests written by agents. Some sources read as promotional, so I kept only claims that two sources agree on. I did not run these rules.
Started from a post by @claudify.tech, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.