Scenario Generator
Systematically generate test scenarios, user stories, and acceptance criteria from requirements. Ensures comprehensive coverage of functional paths, edge cases, and error conditions.
Core Capabilities
1. User Story Generation
Create well-formed user stories:
- As-a/I-want/So-that format - Standard user story structure
- Acceptance criteria - Clear success conditions
- Edge cases - Boundary conditions and exceptions
- Non-functional requirements - Performance, security, usability
- Story prioritization - Business value assessment
- Story sizing - Estimation guidelines
2. Test Scenario Creation
Develop comprehensive test scenarios:
- Happy path scenarios - Expected normal usage
- Alternative paths - Valid variations
- Error scenarios - Invalid inputs and error handling
- Boundary conditions - Min/max values, limits
- State transitions - Different system states
- Concurrency scenarios - Simultaneous operations
3. BDD Scenario Writing
Generate Gherkin-style scenarios:
- Given-When-Then format - Behavior-driven structure
- Scenario outlines - Data-driven test templates
- Background steps - Common preconditions
- Feature organization - Logical grouping
- Tag-based filtering - Scenario categorization
4. Acceptance Criteria Definition
Specify clear success conditions:
- Functional criteria - What the feature must do
- Non-functional criteria - Performance, security, UX
- Negative criteria - What should not happen
- Testable statements - Verifiable conditions
- Definition of Done - Completion checklist
Scenario Generation Workflow
Step 1: Analyze Requirements
Understand what needs to be tested:
Requirements analysis questions:
- What is the main functionality?
- Who are the users/actors?
- What are the inputs and outputs?
- What are the business rules?
- What can go wrong?
- What are the constraints/limitations?
Example requirement:
Requirement: User Login System
Users should be able to log in with email and password.
After 3 failed attempts, the account is locked for 15 minutes.
Password must be at least 8 characters.
Analysis:
- Actors: User, System
- Inputs: Email, password
- Outputs: Login success/failure, account lock
- Business rules: 3 attempts limit, 15-minute lockout, 8-char minimum
- Edge cases: Invalid email, wrong password, locked account, expired session
Step 2: Identify Scenario Types
Categorize scenarios to generate:
Scenario categories:
| Category | Purpose | Examples | |----------|---------|----------| | Happy Path | Normal, expected flow | Valid login, successful purchase | | Alternative Path | Valid variations | Login with remember me, guest checkout | | Boundary | Min/max values | Minimum password length, maximum cart items | | Error Handling | Invalid inputs | Wrong password, network error | | Security | Unauthorized access | SQL injection, XSS attempts | | Performance | Load/stress | 1000 concurrent logins | | State Transition | Different states | Login when already logged in |
Example identification:
For User Login:
- Happy Path: Valid credentials → Success
- Alternative: Remember me checkbox
- Boundary: Exactly 8 characters password
- Error: Wrong password (attempt 1, 2, 3)
- Error: Account locked scenario
- Security: SQL injection in email field
- State: Already logged in user
Step 3: Generate Scenarios
Create specific, testable scenarios:
Scenario structure:
Scenario: [Descriptive name]
Given [Initial context/preconditions]
When [Action/event]
Then [Expected outcome]
And [Additional outcomes]
Example scenarios:
Feature: User Login
Scenario: Successful login with valid credentials
Given a registered user with email "user@example.com"
And the user is on the login page
When the user enters email "user@example.com"
And the user enters password "SecurePass123"
And the user clicks "Login"
Then the user should be logged in
And the user should be redirected to the dashboard
And a session cookie should be created
Scenario: Failed login with incorrect password
Given a registered user with email "user@example.com"
And the user has 0 failed login attempts
When the user enters email "user@example.com"
And the user enters password "WrongPassword"
And the user clicks "Login"
Then the login should fail
And an error message "Invalid email or password" should be displayed
And the failed attempt count should increment to 1
Scenario: Account locked after 3 failed attempts
Given a registered user with email "user@example.com"
And the user has 2 failed login attempts
When the user enters email "user@example.com"
And the user enters password "WrongPassword"
And the user clicks "Login"
Then the account should be locked
And an error message "Account locked. Try again in 15 minutes" should be displayed
And the user cannot login even with correct password
Scenario: Password does not meet minimum length
Given a new user on the registration page
When the user enters password "Short1"
And the user submits the form
Then a validation error should appear
And the error should say "Password must be at least 8 characters"
Step 4: Add Scenario Outlines for Data Variations
Use scenario outlines for data-driven tests:
Format:
Scenario Outline: [Template name]
Given [context with <placeholder>]
When [action with <placeholder>]
Then [outcome with <placeholder>]
Examples:
| placeholder1 | placeholder2 | expected_result |
| value1 | value2 | result1 |
| value3 | value4 | result2 |
Example:
Scenario Outline: Password validation
Given a user on the registration page
When the user enters password "<password>"
Then the validation should be "<result>"
And the message should be "<message>"
Examples:
| password | result | message |
| Short1 | invalid | Password must be at least 8 characters |
| NoDigits | invalid | Password must contain at least one digit |
| nouppercas1 | invalid | Password must contain an uppercase letter |
| NOLOWERCASE1 | invalid | Password must contain a lowercase letter |
| ValidPass1 | valid | Password accepted |
Step 5: Document Acceptance Criteria
Define clear success conditions:
Format:
## User Story
As a [role]
I want [feature]
So that [benefit]
## Acceptance Criteria
- [ ] [Criterion 1]
- [ ] [Criterion 2]
- [ ] [Criterion 3]
## Edge Cases
- [Edge case 1]
- [Edge case 2]
## Definition of Done
- [ ] Code complete
- [ ] Tests passing
- [ ] Documentation updated
Example:
## User Story
As a registered user
I want to log in with my email and password
So that I can access my account securely
## Acceptance Criteria
- [ ] User can log in with valid email and password
- [ ] User sees error message with invalid credentials
- [ ] Account locks after 3 failed attempts for 15 minutes
- [ ] Locked account shows appropriate message
- [ ] Password must be at least 8 characters
- [ ] Login session persists for 7 days with "remember me"
- [ ] User is redirected to dashboard after successful login
## Edge Cases
- User tries to login with locked account
- User logs in while already logged in (different device)
- Password exactly 8 characters long
- Email with special characters
- Network timeout during login
- Session expires while user is active
## Definition of Done
- [ ] All acceptance criteria met
- [ ] All edge cases tested
- [ ] Unit tests coverage >80%
- [ ] Integration tests passing
- [ ] Security review completed
- [ ] Documentation updated
Scenario Generation Patterns
Pattern 1: CRUD Operations
Requirement:
Implement a task management system where