4 / 87 · 02 AI-Augmented Test Design · Prompt Templates for Test Generation← prev⊞ allnext →☰ Read as one page
2.2Template 1: Requirements-to-Tests
Use this when you have a user story with acceptance criteria and need a full test suite.
You are a senior QA engineer. Given the following user story and acceptance
criteria, generate a comprehensive test suite.
**User Story:**
{paste user story here}
**Acceptance Criteria:**
{paste AC here}
**Technical Context:**
- Frontend: {framework and version, e.g., React 18 with React Testing Library}
- API: {API style, e.g., REST endpoints at /api/v2/*}
- Auth: {auth mechanism, e.g., JWT tokens in Authorization header}
**Generate:**
1. Unit tests for the component logic (no API calls)
2. Integration tests for the API layer (mock HTTP)
3. E2E test scenarios (describe steps, no code)
**For each test, include:**
- Test name following the pattern: "should [expected behavior] when [condition]"
- Arrange/Act/Assert structure
- Explicit assertions (not just "expect something")
**Coverage requirements:**
- All acceptance criteria must have at least one test
- Include at least 2 negative/error cases per AC
- Include 1 boundary value test where numeric limits exist
When to Use
- Sprint planning: generate initial test list from stories
- Story refinement: identify missing acceptance criteria by reviewing generated tests
- Onboarding: new team members use this to understand testing expectations
Example Filled-In
You are a senior QA engineer. Given the following user story and acceptance
criteria, generate a comprehensive test suite.
**User Story:**
As a store manager, I want to set a maximum discount percentage per product
category so that sales staff cannot give discounts beyond the allowed limit.
**Acceptance Criteria:**
1. Admin can set max discount (0-100%) per category via the settings page
2. Attempting to apply a discount above the max shows an error toast
3. The max discount persists across browser sessions (stored server-side)
4. Categories with no max set allow any discount (backward compatible)
**Technical Context:**
- Frontend: React 18 with React Testing Library
- API: REST endpoints at /api/v2/settings/discount-limits
- Auth: JWT tokens in Authorization header, requires "admin" role
**Generate:**
1. Unit tests for the DiscountLimitForm component
2. Integration tests for the discount limit API endpoint
3. E2E test scenarios (describe steps, no code)
**For each test, include:**
- Test name following the pattern: "should [expected behavior] when [condition]"
- Arrange/Act/Assert structure
- Explicit assertions (not just "expect something")
**Coverage requirements:**
- All 4 acceptance criteria must have at least one test
- Include at least 2 negative/error cases per AC
- Include boundary value tests for 0%, 1%, 99%, 100%, 101%, and -1%