Generate Test Specifications
Generate BDD-style test specifications for a story in 6 categories. Each category produces two files: main (critical tests) and extended (nice-to-have tests).
Usage
/test-spec "Story name" /test-spec 5 # By MVP story number /test-spec # Interactive selection
Workflow
Phase 1: Context & Story Selection
Read before generating: ProductSpecification/BriefProductDescription.txt, MvpStories.txt, ExpectedLoad.txt, story folder (stories/*/): mockups, *.md, endpoints.md, story-specifics.txt.
Parse input: by name ("Login/Logout"), by number (5), or interactive (list and ask).
Phase 2: Generate Test Files
Create files in ProductSpecification/stories/NN-story-name/tests/:
Main files (critical ~27-34 total tests):
- •
01_API_Tests.md,02_UI_Tests.md,03_Load_Tests.md - •
04_Infrastructure_Tests.md,05_Security_Tests.md,06_Integration_Tests.md
Extended files in extended/ subfolder (nice-to-have edge cases):
- •
extended/01_API_Tests_Extended.md - •
extended/02_UI_Tests_Extended.md - •
extended/03_Load_Tests_Extended.md - •
extended/04_Infrastructure_Tests_Extended.md - •
extended/05_Security_Tests_Extended.md - •
extended/06_Integration_Tests_Extended.md
Add this header to extended files:
> These are additional edge case tests. Implement after core tests pass.
Critical Tests Per Category
01_API_Tests.md (8-12 tests)
Tests are ordered for sequential TDD implementation — each section builds on the previous one. You can implement group N without needing group N+1.
Start every generated file with this header:
> **Implementation Order**: Tests are numbered for sequential TDD implementation. > Start with [story-specific progression summary].
Ordering principles (apply in this priority):
- •Security guards first — auth/CSRF checks. Just need middleware, no business logic.
- •Read operations before writes — GET before POST/PUT/DELETE. Less infrastructure needed.
- •Validation before happy path — within a write group, reject bad input first (needs only validation), then test success (needs full pipeline).
- •Simple states before complex states — default/initial state before edge cases (e.g., trial before grace period).
- •Verification/confirmation flows last — depend on prior operations succeeding (e.g., email verification after registration, webhook after checkout).
Structure: Use ## N. Section Title for groups, ### N.M Scenario Title for individual tests. Separate sections with ---.
Typical section progression (adapt to story — skip irrelevant sections, add story-specific ones):
## 1. Security Foundation ## 2. Read Current State (GET) ## 3. Create/Submit (POST) — Validation ## 4. Create/Submit (POST) — Happy Path ## 5. Verification/Confirmation/Callback ## 6. Additional Operations (PUT/DELETE)
Reference: ProductSpecification/stories/12-billing-and-subscription/tests/01_API_Tests.md
02_UI_Tests.md (5-8 tests)
Same TDD-sequential ordering philosophy. Start with what needs the least code, build up.
Start every generated file with the same > **Implementation Order** header.
Ordering principles:
- •Page display first — render, layout, fields visible. Just needs the component, no logic.
- •Basic interaction before submission — focus, toggles, input. Needs handlers, no API.
- •Form submission with loading state — submit button, spinner. First test triggering API.
- •Client-side validation display — inline errors on blur. Needs validation logic wired.
- •Server response handling — success/error messages. Needs API integration.
- •Navigation and post-action flows — redirects, links to related pages.
Typical section progression:
## 1. Page Display ## 2. User Interaction ## 3. Form Submission ## 4. Validation Feedback ## 5. Server Response Display ## 6. Navigation
03_Load_Tests.md (2-3 tests)
- •Single request response time (<200ms)
- •Concurrent requests (50 users, <500ms)
- •Queue/batch processing performance
04_Infrastructure_Tests.md (2-3 tests)
- •Database connection failure handling
- •Database recovery after failure
- •External service unavailable handling
05_Security_Tests.md (6-8 tests)
- •SQL injection prevention
- •XSS prevention
- •CSRF protection
- •Password hashing verification
- •Rate limiting (brute force protection)
- •Mass assignment protection
- •Input length limits
- •HTTPS enforcement
06_Integration_Tests.md (3-4 tests)
- •External API success flow
- •External API error handling
- •External API timeout handling
- •Token refresh flow
BDD Format Rules
- •Use Gherkin syntax with domain-specific language (DSL)
- •No technical details in scenario steps
- •Fold repeating sequences into reusable statements
- •End each file with DSL Technical Reference table:
## DSL Technical Reference | DSL Statement | Technical Implementation | |---------------|-------------------------| | `an authenticated user` | Valid JWT in Authorization header | | `the user submits registration` | POST /api/auth/register |
Phase 3: Summary
Report: folder path, files created, test counts per file.
Rules
- •English, Gherkin in Markdown, DSL only (no technical details in steps)
- •Main files: critical path (~27-34 total), Extended files: edge cases
- •Reference ExpectedLoad.txt for load tests, OWASP Top 10 for security