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.
In this guide: Learn practical prompting techniques for
test case generation, API testing, automation code generation, and debugging.
What Is Prompt Engineering?
Prompt engineering is the process of designing and improving instructions
given to an AI model to achieve a desired result.
Basic prompt:
Generate test cases for login.
This prompt provides very little context.
Improved prompt:
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.
The second prompt provides context, scope, and a clear output format,
helping the AI generate more relevant suggestions.
1. Use a Clear Prompt Structure
A useful starting point for QA prompts is:
Role + Context + Requirement + Testing Scope + Expected Output
- Role: Act as a software QA engineer.
- Context: An e-commerce application.
- Requirement: Customers can add products to their cart.
- Testing scope: Positive, negative, boundary, and edge cases.
- Expected output: A table containing scenarios and expected results.
You do not need to include every element in every prompt. Add the details
that matter to the task.
2. Prompt for Test Case Generation
Suppose you receive a requirement for a subscription feature.
Try the following prompt:
Example 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:
- Create a subscription with valid customer details.
- Attempt subscription creation with an invalid payment method.
- Verify the behavior when payment fails.
- Retry subscription creation after a failed payment.
- Attempt to create a duplicate subscription.
- Verify that a subscription is not created before successful payment.
Review all generated scenarios against the actual business rules before
using them.
3. Prompt for API Testing
AI can help identify API testing scenarios before you start implementation.
Example prompt
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.
4. Prompt for Automation Code Generation
If you use Playwright, AI can help create a starting point for an automated
test. Try this prompt:
Example 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.
5. Prompt for Debugging Automation Failures
Instead of simply asking AI to fix an error, provide evidence and ask it
to investigate the likely causes.
Example prompt
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.
6. Common Prompt Engineering Mistakes
- Too little context: Important business rules are missing.
- Vague instructions: The desired testing scope is unclear.
- No output format: Results are difficult to review or reuse.
- Unverified assumptions: AI fills gaps with potentially incorrect information.
- Blindly accepting code: Generated automation may be unreliable.
- Sharing confidential data: Sensitive credentials, customer information, and proprietary details should not be shared without appropriate authorization.
7. A Simple Way to Improve Your Prompts
- Start by asking AI to generate test scenarios.
- Add acceptance criteria and business rules.
- Specify positive, negative, boundary, and edge cases.
- Request a structured output.
- Ask AI to identify gaps and assumptions.
- Validate the final output against the actual requirements.
This iterative approach is often more useful than trying to write a perfect
prompt on the first attempt.
Final Thoughts
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.
Better Prompts + QA Expertise + Proper Validation = More Useful AI Assistance
AI can accelerate your testing workflow, but the QA engineer remains
responsible for understanding requirements, assessing risk, and deciding
what should be tested.
Frequently Asked Questions
What is prompt engineering in software testing?
It is the practice of giving AI clear, contextual instructions to assist
with testing activities such as test design, API testing, and automation.
Can prompt engineering improve test case generation?
Clear requirements, testing scope, and output formats can help AI produce
more relevant test case suggestions. The results still require QA review.
Can I use AI to generate Playwright tests?
Yes. AI can generate a starting point for Playwright tests, but selectors,
assertions, waiting strategies, and test behavior should be verified.
Should I share project requirements with AI tools?
Follow your organization's AI and data-security policies. Remove sensitive
information and never share credentials or confidential customer data
without explicit authorization.
Related Reading
Disclaimer: This article is for educational purposes.
AI tools and their capabilities may change over time. Verify generated
technical information and follow your organization's security and
privacy policies.
AI is becoming a useful assistant for software testing. One of the simplest ways
QA engineers can use AI is to generate and review test cases.
Tools such as ChatGPT can help QA engineers think of positive, negative,
boundary, and edge-case scenarios that might otherwise be missed.
However, AI-generated test cases should always be reviewed by a QA engineer
before they are used in a real project.
Key idea: AI should assist the QA engineer, not replace QA
expertise and business understanding.
What Is AI-Assisted Test Case Generation?
AI-assisted test case generation means using an AI tool to create and review
test scenarios based on requirements, user stories, acceptance criteria,
API specifications, or existing functionality.
Instead of manually starting with:
"What test cases should I write for this feature?"
You can provide the requirement to ChatGPT and ask it to identify different
scenarios.
The process can be:
Requirement → AI-generated scenarios → QA review → Final test cases
1. Generate Test Scenarios From a Requirement
Suppose you have the following requirement:
A customer can create a monthly membership using a valid payment method.
The subscription should be created only after successful payment.
You could ask ChatGPT:
Generate positive, negative, boundary, and edge-case test scenarios for
this requirement. Include expected results.
The AI might suggest scenarios such as:
- Create a subscription with valid customer details.
- Create a subscription with a valid payment method.
- Attempt subscription creation with an expired card.
- Attempt subscription creation with an invalid payment method.
- Cancel the payment during the transaction.
- Retry after a failed payment.
- Attempt to create a duplicate subscription.
- Verify that the subscription is created only after successful payment.
This gives the QA engineer a starting point for test design.
2. Generate Positive and Negative Test Cases
A common mistake when creating test cases is focusing mainly on the happy path.
ChatGPT can help expand the scenarios.
You can ask:
Generate positive and negative test cases for a login page.
Include validation, security, and boundary scenarios.
Positive scenarios
- Valid username and password.
- Valid credentials with different supported browsers.
Negative scenarios
- Invalid username.
- Invalid password.
- Empty username.
- Empty password.
- Both fields empty.
- Account locked after multiple failed attempts.
This can help improve test coverage during the initial test-design phase.
3. Find Boundary and Edge Cases
Boundary conditions are often important in software testing.
Suppose a field allows a maximum of 50 characters.
You can ask ChatGPT:
Identify boundary and edge cases for a field that accepts a maximum
of 50 characters.
You might get scenarios such as:
- 0 characters
- 1 character
- 49 characters
- 50 characters
- 51 characters
- Special characters
- Spaces
- Unicode characters
The QA engineer can then decide which scenarios are actually applicable
to the application.
4. Convert Requirements Into a Test Case Table
You can also ask ChatGPT to structure scenarios into a test case format.
For example:
Convert this requirement into test cases with Test Case ID, Scenario,
Steps, Test Data, and Expected Result.
A simple output could look like:
| ID |
Scenario |
Expected Result |
| TC01 |
Login with valid credentials |
User successfully logs in |
| TC02 |
Login with invalid password |
Appropriate error is displayed |
| TC03 |
Login with empty password |
Validation message is displayed |
| TC04 |
Login with locked account |
Login is prevented |
5. Improve Existing Test Cases
ChatGPT doesn't have to create test cases from scratch.
You can provide existing test cases and ask:
Review these test cases and identify missing scenarios, duplicate cases,
unclear steps, and opportunities to improve coverage.
AI may help identify:
- Missing negative scenarios
- Missing boundary cases
- Duplicate test cases
- Unclear expected results
- Missing validation
- Missing error scenarios
The QA engineer should then decide which suggestions are relevant.
A Better Prompt for QA Engineers
The quality of the AI output depends heavily on the information provided.
Instead of asking:
"Create test cases for login."
Provide more context:
Create functional test cases for a login page. The username is mandatory,
the password must contain at least 8 characters, and the account is locked
after 5 consecutive failed attempts. Include positive, negative, boundary,
and security-related scenarios.
The second prompt gives the AI much more useful information.
A Simple Prompt Structure
A useful structure for QA prompts is:
Context + Requirement + Testing Scope + Expected Output
For example:
You are helping a QA engineer test an e-commerce application.
Generate test scenarios for the checkout feature. Include positive,
negative, boundary, payment failure, and validation scenarios.
Present the results in a table with Scenario, Test Data, and Expected Result.
Don't Trust AI-Generated Test Cases Blindly
This is one of the most important points.
ChatGPT can generate useful scenarios, but it does not automatically
understand your complete business context.
It may:
- Make incorrect assumptions.
- Miss important business rules.
- Generate duplicate scenarios.
- Suggest scenarios that aren't applicable.
- Miss project-specific integrations.
- Produce technically incorrect expectations.
Therefore, the QA engineer should always review the generated test cases.
Remember: Treat AI as a test-design assistant, not the
final decision-maker.
Best Practices
When using ChatGPT for test case generation:
- Provide enough business context.
- Include acceptance criteria whenever possible.
- Ask for positive and negative scenarios.
- Ask specifically for boundary and edge cases.
- Review the generated test cases manually.
- Remove duplicate or irrelevant scenarios.
- Never share confidential or sensitive project information unnecessarily.
- Validate the final test cases against the actual application behavior.
Final Thoughts
ChatGPT can reduce the effort required to create and review test cases.
It can help QA engineers explore different scenarios, identify potential
gaps, and improve test coverage.
However, the most effective approach is not
AI instead of QA.
QA Expertise + AI Assistance = Better Test Design
The QA engineer still owns the testing strategy, business understanding,
risk assessment, and final decision about what should be tested.
Frequently Asked Questions
Can ChatGPT generate complete test cases?
Yes. ChatGPT can generate test scenarios and test cases from requirements,
but QA engineers should review and validate them before using them.
Can ChatGPT replace a QA engineer?
No. AI can assist with test design and documentation, but understanding
business risk, requirements, application behavior, and testing strategy
still requires human expertise.
What information should I provide to ChatGPT?
Provide relevant requirements, acceptance criteria, business rules,
validation rules, supported platforms, and the type of testing required.
Avoid sharing confidential or sensitive project information.
Can ChatGPT help find missing test scenarios?
Yes. You can provide your existing test cases and ask ChatGPT to identify
potential gaps, duplicate scenarios, boundary cases, and additional
negative scenarios.
Related Reading
Disclaimer:
This article is provided for educational and informational purposes.
AI tools and their capabilities may change over time. Always verify
important technical information and follow your organization's security,
privacy, and AI usage policies.