|

Stop Getting Generic AI Tests: The Prompt Engineering Guide for QA Engineers

Most QA engineers get mediocre AI-generated tests because the prompt is the problem, not the AI. A generic prompt gets generic results. A structured prompt gets comprehensive edge-case coverage.

Contents

Generic vs Structured Prompts

Generic Prompt (Bad)

"Generate test cases for the login page"

Result: 5 basic happy-path tests. No edge cases. No security. No error handling.

Structured Prompt (Good)

"Generate test cases for the login page of an e-commerce application.

Context:
- Authentication uses JWT tokens with 30-minute expiry
- Login supports email + password and Google OAuth
- After 5 failed attempts, account locks for 15 minutes
- Password requirements: 8+ chars, 1 uppercase, 1 number, 1 special

Include test types:
- Positive: valid credentials, remember me, redirect after login
- Negative: wrong password, non-existent email, locked account
- Boundary: password at exactly 8 chars, 5th vs 6th failed attempt
- Security: SQL injection in email field, XSS in password, CSRF token validation
- Performance: login response time under 2 seconds
- Accessibility: keyboard navigation, screen reader labels, error announcement

Format: Playwright TypeScript with Page Object Model pattern"

Result: 25+ comprehensive tests covering every edge case. Production-grade quality.

The 6 Elements of a High-Quality Test Prompt

  1. Context — what the feature does, business rules, tech stack
  2. Scope — which scenarios to cover (positive, negative, boundary)
  3. Test types — functional, security, performance, accessibility
  4. Edge cases — specific boundary conditions to explore
  5. Format — framework, language, patterns (POM, fixtures)
  6. Constraints — locator preferences, naming conventions, assertion style

Copy-Paste Prompt Templates

Template: Payment Flow

"Generate Playwright tests for a payment checkout flow.
Context: Stripe integration, supports credit card and PayPal.
Include: successful payment, declined card, expired card,
insufficient funds, network timeout during processing,
double-click prevention on submit button, amount validation
(min $1, max $10,000), currency formatting.
Security: PCI compliance - card numbers never logged.
Format: TypeScript, Page Object Model, API mocking for Stripe."

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.