Test writer
Generates comprehensive unit and integration tests for a given file or function, auto-detecting the project test framework and matching existing test style.From its SKILL.md
npx -y skills add RealDougEubanks/ClaudeMarketplace --skill test-writerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.4 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
Test Writer
Generate comprehensive unit and integration tests for a given file or function, auto-detecting the project test framework and matching the existing test style.
Instructions
When invoked via /test-writer:
-
Identify the target. Ask the user: which file or function should tests be written for? Accept:
- An absolute or relative file path (e.g.
src/utils/parser.ts) - A function or method name (ask which file it lives in if ambiguous)
- An absolute or relative file path (e.g.
-
Read the target file using Read. Understand:
- All exported/public functions, classes, and methods
- Their parameter types, return types, and documented or inferred behavior
- Dependencies (imports/requires) that will need to be mocked
-
Detect the test framework using Glob and Read:
- Jest: look for
jest.config.*, or"jest"key inpackage.json - Vitest: look for
vitest.config.*, or"vitest"inpackage.jsondevDependencies - pytest: look for
pytest.ini,pyproject.tomlcontaining[tool.pytest.ini_options], orconftest.py - Go test: look for
go.modand any existing*_test.gofiles - PHPUnit: look for
phpunit.xmlorphpunit.xml.dist, orphpunit/phpunitincomposer.json - Mocha: look for
.mocharc.*, or"mocha"inpackage.jsondevDependencies - RSpec: look for
.rspec,spec/spec_helper.rb, orrspecinGemfile - JUnit: look for
junitinpom.xmlorbuild.gradle/build.gradle.kts - xUnit / NUnit / MSTest: look for
xunit,NUnit, orMSTestpackage references in*.csproj - If multiple are present, ask the user which to use.
- Jest: look for
-
Match existing test style. Use Glob to find existing test files matching
**/*.test.*,**/*.spec.*,**/*_test.*, ortests/**/*. Read 1–2 representative test files to capture:- Describe/context block structure
- Assertion library and style (
expect,assert,should) - How mocks, stubs, and fixtures are set up
- Import paths and module resolution patterns
-
Determine the test file location and name:
- If existing tests are co-located (e.g.
src/foo.ts→src/foo.test.ts), follow that pattern. - If existing tests live in a
tests/or__tests__/directory, mirror the source path there. - If no existing tests exist, default to co-located.
- If existing tests are co-located (e.g.
-
Generate tests covering:
- Happy path: normal, valid inputs produce the expected output
- Edge cases: empty string/array, zero,
null/undefined/None, maximum values, boundary conditions (e.g. off-by-one) - Invalid input: wrong type, missing required fields, malformed data — verify errors are thrown or returned correctly
- Error conditions: simulate dependency failures using mocks/stubs; verify the function handles them gracefully
- All public functions/methods in the target file — do not skip any exported surface
Follow the detected framework's idioms exactly. Use the same describe block nesting, assertion style, and mock setup patterns found in existing tests.
-
Write the test file:
- If the test file does not exist, use Write to create it.
- If the test file already exists, use Read to review it, then use Edit to append new test cases — never overwrite existing tests.
-
Run the tests using Bash. For JS/TS frameworks, prefer the project's own test script or local binary — do not use
npx, which can download and execute a package from the network if it isn't installed locally:- Jest/Vitest/Mocha:
npm test -- <testfile>ifpackage.jsondefines a test script; otherwisenode_modules/.bin/jest <testfile>(orvitest run/mocha). If neither exists, ask the user before falling back tonpx. - pytest:
python -m pytest <testfile> -v - Go:
go test ./... -run <TestName> - PHPUnit:
vendor/bin/phpunit <testfile> - RSpec:
bundle exec rspec <testfile> - JUnit:
mvn test -Dtest=<TestClass>orgradle test --tests <TestClass> - xUnit/NUnit/MSTest:
dotnet test --filter <TestClass> - Report pass/fail counts and any error output.
- If tests fail, diagnose the root cause (missing mock, wrong import path, API mismatch) and fix before finishing. Do not leave the user with a broken test file.
- Jest/Vitest/Mocha:
Output Format
After writing and running tests, summarize:
## Test Writer — <target file> — <date>
### Framework Detected
<framework name and version if available>
### Test File Written
`<path/to/test-file>`
### Coverage
| Function / Method | Tests Written |
|-------------------|---------------|
| functionName | 4 (happy, edge, invalid, error) |
| anotherFunction | 3 (happy, edge, error) |
### Run Results
Tests: X passed, Y failed, Z total
### Notes
<Any caveats — e.g. "mock for ExternalService is approximate; update if the interface changes">
Notes
- This skill writes tests only — it does not modify production code.
- If the target file has no exports or public surface (e.g. it is a CLI entry point), generate integration-style tests that exercise the module end-to-end via its public interface or subprocess.
- Prefer deterministic tests. Avoid
Date.now(),Math.random(), or other non-deterministic values in assertions without mocking them first.
What ships with it: 3 files
4.0 KB alongside SKILL.md
.claude-plugin/
- plugin.json484 B
- metadata.json590 B
- README.md3.0 KB