Read spec artifacts (spec.md, plan.md, tasks.md) and generate ready-to-fill test scaffolds that cover every acceptance criterion, user scenario, and success criterion. Tests are organized by requirement and include descriptive names, setup hints, and assertion placeholders.
-
Extract Testable Requirements: Parse spec artifacts to build a complete list of things to test.
- From
spec.md → ## Requirements: Each requirement becomes a test suite
- From
spec.md → ## User Scenarios & Testing: Each scenario becomes a describe/context block
- From
spec.md → ## Success Criteria: Each criterion becomes one or more test cases
- From
plan.md → Technical decisions: Each decision becomes a verification test
- Assign each testable item a stable ID (TEST-001, TEST-002, etc.)
-
Detect Test Environment: Identify the project's testing setup.
- Detect language: TypeScript, JavaScript, Python, Go, Java, Rust, etc.
- Detect framework: Jest, Vitest, Mocha, pytest, unittest, go test, JUnit, etc.
- Detect existing test directory structure and naming conventions
- If no test setup exists, recommend one based on the project's language
-
Generate Test File Structure: Create test files organized by requirement.
tests/
├── unit/
│ ├── auth/
│ │ ├── signup.test.ts ← REQ-001: User signup
│ │ ├── login.test.ts ← REQ-002: User login
│ │ └── token.test.ts ← REQ-003: JWT generation
│ └── middleware/
│ └── rateLimit.test.ts ← REQ-004: Rate limiting
├── integration/
│ └── auth-flow.test.ts ← Scenario: Full auth flow
└── e2e/
└── user-registration.test.ts ← Scenario: New user registration
-
Generate Test Scaffolds: For each requirement, produce a test file with:
Example (TypeScript/Jest):
describe('User Signup', () => {
describe('successful registration', () => {
it('should create a new user with valid email and password', () => {
throw new Error('TODO: implement test');
});
it('should hash the password before storing', () => {
throw new Error('TODO: implement test');
});
});
describe('duplicate email handling', () => {
it('should reject signup with existing email', () => {
throw new Error('TODO: implement test');
});
});
describe('email validation', () => {
it('should reject invalid email formats', () => {
throw new Error('TODO: implement test');
});
});
});
Example (Python/pytest):
"""
Tests for REQ-001: User signup with email/password
Source: spec.md → Requirements → "Users can sign up with email and password"
Implementation: src/auth/signup.py
"""
import pytest
class TestUserSignup:
"""Acceptance Criteria: Valid email and password creates account"""
def test_creates_user_with_valid_credentials(self):
raise NotImplementedError("TODO: implement test")
def test_hashes_password_before_storing(self):
raise NotImplementedError("TODO: implement test")
def test_rejects_duplicate_email(self):
raise NotImplementedError("TODO: implement test")
-
Generate Traceability Header: Each test file includes a header comment linking back to the spec.
Requirement: REQ-001
Spec Section: ## Requirements → "Users can sign up with email/password"
Implementation: src/auth/signup.ts
Plan Reference: plan.md → "Use bcrypt with cost factor 12"
-
Output Summary: Report what was generated.
## Generated Test Scaffolds
| Requirement | Test File | Test Cases | Type |
|-------------|-----------|------------|------|
| REQ-001: User signup | tests/unit/auth/signup.test.ts | 4 | Unit |
| REQ-002: User login | tests/unit/auth/login.test.ts | 3 | Unit |
| REQ-003: JWT tokens | tests/unit/auth/token.test.ts | 5 | Unit |
| Scenario: Auth flow | tests/integration/auth-flow.test.ts | 3 | Integration |
| Scenario: Registration | tests/e2e/user-registration.test.ts | 2 | E2E |
**Total: 17 test cases across 5 files**