| name | test_generation |
| description | Generates comprehensive unit and integration tests with edge case coverage. Invoke when user requests test creation, test coverage improvement, or before committing new features. |
SKILL: Automated Test Generation
🎯 Objective
Generate thorough, meaningful test suites for code changes. Focus on business logic validation, edge cases, and error scenarios rather than trivial syntax checks.
🧠 Core Principle: Test Real Behavior
Write tests that verify actual business outcomes and failure modes. Avoid over-mocking that renders tests meaningless. Each test must assert something non-obvious about the code's behavior.
📊 Quality Legend
STRONG — Test can fail for a real reason and pins business behavior.
WEAK — Test passes trivially or asserts implementation detail; rewrite.
MISSING — A branch/edge/error path has no coverage; add it.
✅ Verification Discipline
The litmus test: if you mutate the logic, does a test fail? If a test still passes after you break the function, it is WEAK. Prefer asserting on outputs and observable side effects over asserting that a mock was called.
🚫 Reject These Anti-Patterns
expect(true).toBe(true);
jest.mock('./calculateTax');
expect(calculateTax(100)).toBe(mockedValue);
expect(db.save).toHaveBeenCalled();
🛠️ Execution Pipeline
1. ANALYZE_FUNCTION_SIGNATURE
Goal: Know the contract before writing a single assertion.
2. HAPPY_PATH_TESTS
Goal: Lock in correct behavior for valid inputs.
Example:
it('applies 8.25% tax to a subtotal', () => {
expect(calculateTotal({ subtotal: 100, taxRate: 0.0825 })).toBe(108.25);
});
3. EDGE_CASE_TESTS
Goal: Cover the boundaries where bugs hide.
4. ERROR_HANDLING_TESTS
Goal: Prove failures are handled, not hidden.
Example:
await expect(fetchUser(-1)).rejects.toThrow('user id must be positive');
5. INTEGRATION_TESTS (When Applicable)
Goal: Verify components work together against real boundaries.
6. MOCK_STRATEGY
Goal: Mock the edges of the system, never its core.
7. PROPERTY_BASED_TESTS (When Applicable)
Goal: Assert invariants that must hold for all valid inputs.
Example:
fc.assert(fc.property(fc.string(), s => decode(encode(s)) === s));
8. TEST_ORGANIZATION
Goal: Tests read as living specification.
📤 Output Directives
Generate test code in the project's existing testing framework — detect it from the dependency manifest (Jest, Vitest, Mocha, pytest, JUnit, Go testing, etc.) rather than introducing a new one. Use descriptive test names that explain the scenario. Group related tests with describe blocks.
Coverage target: 80%+ lines, but coverage is a floor, not the goal — every branch and error path matters more than the percentage. Prefer one strong behavioral test over five trivial ones.
After generating, run the suite and confirm it passes before reporting done.