Prompt Engineering for QA Engineers: Practical Examples and Prompts
Generative AI tools such as ChatGPT, Claude, and Gemini are becoming useful
assistants for software testing. But the quality of their responses
depends heavily on how we ask questions and provide context.
This is where prompt engineering becomes important.
For QA engineers, prompt engineering means giving AI clear instructions,
relevant requirements, testing scenarios, and an expected output format
to get more useful results.
Prompt engineering is the process of designing and improving instructions
given to an AI model to achieve a desired result.
Basic prompt:
This prompt provides very little context.
Improved prompt:
The second prompt provides context, scope, and a clear output format,
helping the AI generate more relevant suggestions.
A useful starting point for QA prompts is:
You do not need to include every element in every prompt. Add the details
that matter to the task.
Suppose you receive a requirement for a subscription feature.
Try the following prompt:
Act as an experienced QA engineer. Based on the requirement below,
generate functional test scenarios for subscription creation. Include
positive, negative, boundary, payment failure, duplicate submission,
and error-handling scenarios. Provide the scenario, preconditions,
test steps, test data, and expected result in a table.
Requirement: A customer can create a subscription using a valid payment
method. The subscription should be created only after successful payment.
Possible scenarios include:
Review all generated scenarios against the actual business rules before
using them.
AI can help identify API testing scenarios before you start implementation.
Act as an API testing specialist. Review the API specification below
and suggest scenarios for successful requests, missing fields, invalid
data types, invalid authentication, unauthorized access, boundary values,
error responses, and duplicate requests. Include expected HTTP status
codes only when supported by the specification. Clearly identify assumptions.
Provide the relevant API specification or sanitized request and response
examples. AI-generated status codes and expected responses must be verified
against the actual API contract.
If you use Playwright, AI can help create a starting point for an automated
test. Try this prompt:
Act as a Playwright test automation engineer using TypeScript.
Write a test for the login feature using the requirements below.
Use stable locators, meaningful assertions, and appropriate waiting
strategies. Avoid fixed timeouts unless necessary. Explain assumptions
and identify selectors that need to be verified against the application.
Include the login requirements and example HTML or accessible selectors
when available.
Always execute and review the generated code. AI may invent selectors,
misunderstand application behavior, or produce code that needs adjustments.
Instead of simply asking AI to fix an error, provide evidence and ask it
to investigate the likely causes.
Help me investigate this Playwright test failure. Analyze the error
message, relevant test code, and available logs. Identify the most likely
causes, explain how to verify each cause, and suggest the smallest
appropriate code change. Do not assume the application is defective
without evidence.
Include the relevant error message, a sanitized code snippet, and useful
logs. This encourages investigation rather than an unsupported code change.
This iterative approach is often more useful than trying to write a perfect
prompt on the first attempt.
Prompt engineering is a practical skill for modern QA engineers. It can help
with test design, API testing, automation code generation, debugging,
and documentation.
The key is to provide clear context, define the task, specify the expected
output, and verify the result.
AI can accelerate your testing workflow, but the QA engineer remains
responsible for understanding requirements, assessing risk, and deciding
what should be tested.
It is the practice of giving AI clear, contextual instructions to assist
with testing activities such as test design, API testing, and automation.
Clear requirements, testing scope, and output formats can help AI produce
more relevant test case suggestions. The results still require QA review.
Yes. AI can generate a starting point for Playwright tests, but selectors,
assertions, waiting strategies, and test behavior should be verified.
Follow your organization's AI and data-security policies. Remove sensitive
information and never share credentials or confidential customer data
without explicit authorization.
What Is Prompt Engineering?
Generate test cases for login.
You are assisting a QA engineer testing a web application's login feature.
The username and password are mandatory. Generate positive, negative,
boundary, and security-related test scenarios. Present the results in a
table with Scenario, Test Data, and Expected Result.
1. Use a Clear Prompt Structure
2. Prompt for Test Case Generation
3. Prompt for API Testing
4. Prompt for Automation Code Generation
5. Prompt for Debugging Automation Failures
6. Common Prompt Engineering Mistakes
7. A Simple Way to Improve Your Prompts
Final Thoughts
Frequently Asked Questions
What is prompt engineering in software testing?
Can prompt engineering improve test case generation?
Can I use AI to generate Playwright tests?
Should I share project requirements with AI tools?
Related Reading
Category: AI for QA, ChatGPT, Generative AI, Prompt Engineering, QA Automation, Software Testing

0 comments