AI

Bridging prompt engineering and QA

4 mins

Intro

Prompt engineering is the skill of writing effective instructions for AI models so they produce useful, accurate, or creative results.

Prompt techniques

In QA work, good prompts help testers generate test cases, analyze bugs, and explore edge scenarios faster. Below are the most common prompt techniques with simple QA related examples.

1. Instruction prompting

Giving clear, direct instructions to guide the model.

Generate fake data for an e-commerce checkout form. Include fields for full name, email, shipping address, billing address, phone number, and payment method.
Full name: Emily Carter
Email: emily.carter@example.com
Shipping address: 123 Maple Street, Springfield, IL 62704
Billing address: 456 Oak avenue, Springfield, IL 62705
Phone number: +1 217-555-0198
Payment method: Visa
2. Zero-shot prompting

Asking the model to perform a task without giving any examples.

Explain why software testing is important.
Software testing ensures that applications work correctly, securely, and meet user expectations before release.
3. Few-shot prompting

Providing a few examples to guide the model's behavior.

Bug: Login button misaligned
Severity: low

Bug: App crashes on launch
Severity: critical

Bug: Typo in settings page
Severity: minor

Bug: Payment fails with valid card
Severity: ?

Classify the severity of the last bug.
Severity: critical
4. Exclusion prompting

Telling the model what not to do.

List five high-priority test cases for a new user registration form. Do not include any test cases related to the password field.
1. Invalid email structure: Verify rejection of emails missing the @ symbol or domain.
2. Duplicate user: Attempt registration using an email already present in the system.
3. Missing required fields: Try submitting the form with an empty username field.
4. Maximum length check: Enter a full name that exceeds the defined character limit.
5. Unaccepted terms: Confirm submission fails if the Terms of service checkbox isn't selected.
5. Role-based prompting

Asking the model to act as a specific persona or expert.

You are a QA engineer. Review the following feature description and identify potential test scenarios.

Feature: Users can schedule meetings by selecting a date, time, and participants from their contact list.
Potential test scenarios:

- Schedule a meeting with valid date, time, and participants.
- Attempt to schedule a meeting without selecting a date.
- Attempt to schedule a meeting with a past date.
- Add participants who are not in the contact list.
- Schedule overlapping meetings.
- Verify confirmation message after scheduling.
6. Chain-of-thought prompting

Encouraging the model to reason step-by-step before giving the final answer.

Design a test case for the password reset feature.

Let's think step by step:

1. What is the expected user flow for resetting a password?
2. What inputs are required (e.g., email, verification code)?
3. What validations should be in place?
4. What should happen after a successful reset?
5. What edge cases should be considered?

Based on this reasoning, write a test case.
Test case: password reset flow

Steps:

1. Navigate to the login page and click Forgot password.
2. Enter a registered email address.
3. Receive and enter the verification code.
4. Enter a new valid password and confirm it.
5. Submit the form.

Expected result:

- User receives a confirmation message.
- User can log in with the new password.
- Old password no longer works.

Edge cases:

- Invalid email format.
- Unregistered email.
- Expired or incorrect verification code.
- Weak password input.
7. System prompting

System prompting sets the core rules that guide an AI’s behavior throughout a session. It’s the base layer that all other prompts build upon in long-running chats.

Example of system prompt:

You are an experienced QA Automation Engineer specializing in web applications. Always reason like a tester: focus on reliability, edge cases, and reproducibility. When analyzing bugs, describe possible root causes and ways to verify fixes. Use concise, technical language suitable for QA documentation.

Generate test cases for the login form with both valid and invalid inputs.
1. Valid credentials: user logs in successfully
2. Empty password field: display Password required
3. SQL injection attempt: reject input and log security warning
8. Retrieval-augmented generation (RAG)

Combines AI reasoning with information pulled from an external knowledge base.

Before generating a response, the AI retrieves relevant facts or documents and uses them to produce a more accurate, evidence-based answer. This approach is currently the most advanced method for improving factual reliability.

Resources