Test Writer
Write tests for a target file or function that fit how the project already tests things.
When to use
When the user asks to add tests, improve coverage, or test a specific module.
Procedure
- Find the project's test setup before writing anything:
- Look for existing test files (
*.test.*,*.spec.*, atests/or__tests__/folder). - Identify the framework and assertion style from those files, for example Vitest, Jest, Pytest, or Go testing.
- Note the project's patterns: how it names tests, sets up fixtures, and mocks dependencies.
- Look for existing test files (
- Read the code under test fully. List the behaviors worth covering: the happy path, each branch, boundary values, and error handling.
- Write tests that mirror the existing patterns exactly. Do not introduce a new framework or style.
- Cover the cases from step 2. Prefer a few clear, meaningful tests over many shallow ones.
- Run the tests. If any fail, decide whether the test or the code is wrong, fix the right one, and re-run until green or until you have a genuine finding to report.
Notes
- Match the project, do not impose your own preferences.
- A test that always passes is worse than no test. Each test should be able to fail for a real reason.