- Jul 19, 2026
- admin
- 0
Using ChatGPT to Generate Test Cases
ChatGPT can significantly speed up test design by generating functional, negative, boundary, security, and exploratory test scenarios from requirements or user stories. However, the generated test cases should always be reviewed by a QA engineer to ensure they match the application’s business rules.
Why Use ChatGPT for Test Case Generation?
Benefits
- Saves time creating test cases
- Improves test coverage
- Generates positive and negative scenarios
- Suggests edge cases
- Creates boundary value tests
- Helps identify missing requirements
- Generates API and database test scenarios
- Produces BDD scenarios
- Assists junior QA engineers
Step 1: Provide Clear Requirements
Instead of asking:
Generate login test cases.
Provide detailed requirements.
Example Requirement
Application: Online Shopping Portal
Login Requirements:
• Username is mandatory.
• Password is mandatory.
• Username must be a valid email address.
• Password must contain at least 8 characters.
• After 5 failed login attempts, the account is locked for 30 minutes.
• Forgot Password link is available.
• Successful login redirects users to the dashboard.
The more context you provide, the better the output.
Step 2: Use an Effective Prompt
Example Prompt
You are a Senior QA Engineer.
Generate comprehensive test cases for the following login functionality.
Include:
• Positive test cases
• Negative test cases
• Boundary value analysis
• Equivalence partitioning
• Security test cases
• UI validation
• Usability test cases
Present the output in a table with:
Test Case ID
Scenario
Preconditions
Test Steps
Expected Result
Priority
Step 3: Review the Generated Test Cases
Example output:
| ID | Test Scenario | Expected Result |
|---|---|---|
| TC001 | Login with valid username and password | Dashboard displayed |
| TC002 | Invalid password | Error message displayed |
| TC003 | Invalid email format | Validation message shown |
| TC004 | Blank username | Username required |
| TC005 | Blank password | Password required |
| TC006 | Both fields blank | Mandatory field validation |
| TC007 | Password with 7 characters | Validation error |
| TC008 | Five failed login attempts | Account locked |
| TC009 | Forgot Password link | Reset page opens |
| TC010 | SQL Injection attempt | Login blocked |
| TC011 | XSS payload in username | Input sanitized |
| TC012 | Session timeout | Redirect to login page |
Generate Boundary Value Test Cases
Prompt:
Generate boundary value test cases for the Password field.
Rules:
Minimum length = 8
Maximum length = 20
| Input | Expected Result |
|---|---|
| 7 characters | Rejected |
| 8 characters | Accepted |
| 9 characters | Accepted |
| 19 characters | Accepted |
| 20 characters | Accepted |
| 21 characters | Rejected |
Generate API Test Cases
Prompt:
Generate REST API test cases for the Login API.
Request:
POST /login
Fields:
email
password
Include:
Positive
Negative
Security
Performance
Authorization
- Valid credentials
- Invalid password
- Missing email
- Missing password
- Invalid JSON
- Invalid Content-Type
- SQL Injection payload
- XSS payload
- Rate limiting
- Large request body
- Response time validation
- Invalid token
Generate Exploratory Testing Ideas
Prompt:
Suggest exploratory testing scenarios for an online banking application.
- Navigate rapidly between pages
- Refresh during money transfer
- Open multiple browser tabs
- Use browser back button
- Interrupt network connectivity
- Test session timeout
- Upload unsupported files
- Test concurrent user actions
Generate Security Test Cases
Prompt:
Generate security test cases for a login page.
Include:
SQL Injection
XSS
CSRF
Session Management
Authentication
Authorization
- SQL injection in username
- XSS payload in password
- Brute-force login attempts
- Weak password policy
- Cookie tampering
- Session fixation
- Logout and browser back button
- Unauthorized URL access
Generate Test Data
Prompt:
Generate 50 valid and invalid email addresses for testing.
- Phone numbers
- Credit card formats (non-real)
- ZIP/postal codes
- Names
- Addresses
- Dates
- Random IDs
Generate BDD Scenarios
Prompt:
Generate Gherkin scenarios for Login functionality.
Feature: Login
Scenario: Successful Login
Given the user is on the Login page
When the user enters valid credentials
And clicks Login
Then the Dashboard should be displayed
Generate Automation Scripts
Prompt:
Generate Playwright TypeScript automation for Login.
test('Successful Login', async ({ page }) => {
await page.goto('https://example.com');
await page.fill('#email', 'user@example.com');
await page.fill('#password', 'Password123');
await page.click('button[type="submit"]');
await expect(page).toHaveURL(/dashboard/);
});
Best Prompt Templates
Template 1 – Functional Testing
Generate detailed functional test cases for:
<Application Name>
Include:
Positive
Negative
Boundary
Validation
Business Rules
Output as a table.
Template 2 – API Testing
Generate REST API test cases.
API:
<Request>
Include:
Status Codes
Headers
Authentication
Security
Performance
Invalid Requests
Template 3 – Automation
Generate Playwright TypeScript automation scripts for:
<Application Feature>
Use:
Page Object Model
Assertions
Best Practices
Template 4 – Bug Report
Create a professional bug report.
Include:
Title
Steps
Expected
Actual
Environment
Severity
Priority
Best Practices
- Provide complete requirements and business rules.
- Specify the desired output format (table, BDD, checklist, etc.).
- Ask for positive, negative, boundary, and edge-case scenarios.
- Request security, performance, and usability test ideas where applicable.
- Review AI-generated test cases for accuracy and completeness.
- Update the generated test cases to reflect organization-specific requirements.
Common Mistakes to Avoid
- Using vague prompts with little context.
- Assuming AI-generated test cases are complete.
- Ignoring business-specific validation rules.
- Not validating edge cases manually.
- Skipping reviews before adding test cases to your test repository.
Example Workflow
Requirements
│
▼
Create a Detailed Prompt
│
▼
ChatGPT Generates Test Cases
│
▼
QA Reviews and Refines
│
▼
Add Missing Business Scenarios
│
▼
Convert to Automation (Playwright/Selenium)
│
▼
Execute Tests
│
▼
Analyze Results

