In this lesson, we will explore how to structure prompts effectively to generate efficient and comprehensive test cases based on a provided requirements document. By learning how to use AI to generate test cases, you can save time and reduce costs. Be cautious when using external AI tools, as it may conflict with company policies.
Step-by-Step Prompt Refinement for Generating Test Cases
Here are three example prompts that guide you in generating relevant test cases. You can use tools like ChatGPT, Gemini, or Copilot for this exercise.
Prompt 1: Functional Test Cases Without Test Data
Prompt: “Can you create functional test cases for user accounts and the product catalog, using a test case ID, description, and expected outcome?”
This prompt generates a basic set of functional test cases without specific test data. Here’s an example output:
Functional Test Cases for “Book Style” Online Bookstore Platform
User Accounts Functional Test Cases
Test Case ID | Test Case Description | Expected Outcome |
---|---|---|
UA-01 | Register a new user account with valid details (email, password, etc.). | Account is created successfully; confirmation email is sent. |
UA-02 | Attempt registration with an existing email. | Registration is blocked; error message indicating duplicate email is displayed. |
UA-03 | Log in with valid credentials. | User is logged in successfully and directed to the homepage. |
UA-04 | Attempt login with incorrect email/password. | Login fails; error message is displayed indicating invalid credentials. |
UA-05 | Update personal details (e.g., name, address) in profile. | Profile updates are saved and reflected on the profile page. |
UA-06 | View order history, including previous order details and status. | Order history page displays with details of past orders. |
UA-07 | Initiate password reset for a registered email. | Password reset link is sent to the provided email. |
UA-08 | Log out from any page on the platform. | User is logged out and redirected to the login page. |
Product Catalog Functional Test Cases
Test Case ID | Test Case Description | Expected Outcome |
---|---|---|
PC-01 | Browse books by selecting a specific genre from the catalog. | Books related to the selected genre are displayed. |
PC-02 | Search for books using a keyword (e.g., title, author). | Search results display relevant books matching the keyword. |
PC-03 | Apply filters (e.g., price, format) to narrow down book listings. | Results display only books matching the selected filter criteria. |
PC-04 | View a book’s detail page (including description, author bio, reviews). | Detailed information about the selected book is displayed. |
PC-05 | Add a book to the shopping cart from the catalog or detail page. | Book is added to the cart, and the cart count is updated. |
PC-06 | Remove a book from the shopping cart. | Book is removed from the cart, and the cart updates accordingly. |
PC-07 | Save a book for later instead of adding it to the cart. | Book is saved in the ‘Save for Later’ section and accessible there. |
PC-08 | View personalized book recommendations based on browsing history or preferences. | Recommendations display relevant books personalized for the user. |
Prompt 2: Refine to Include Test Data
To make each test case more actionable, refine your prompt to include specific test data.
Refined Prompt: “Can we also have test data for each combination? Add this to the table above.”
Functional Test Cases for User Accounts and Product Catalog (with Test Data)
User Accounts Functional Test Cases
Test Case ID | Test Case Description | Test Data | Expected Outcome |
---|---|---|---|
UA-01 | Register a new user account with valid details (email, password, etc.). | Email: user1@example.com, Password: Test@1234 | Account is created successfully; confirmation email is sent. |
UA-02 | Attempt registration with an existing email. | Email: existinguser@example.com, Password: Test@1234 | Registration is blocked; error message indicating duplicate email is displayed. |
UA-03 | Log in with valid credentials. | Email: user1@example.com, Password: Test@1234 | User is logged in successfully and directed to the homepage. |
UA-04 | Attempt login with incorrect email/password. | Email: user1@example.com, Password: WrongPass123 | Login fails; error message is displayed indicating invalid credentials. |
UA-05 | Update personal details (e.g., name, address) in profile. | Name: John Doe, Address: 123 Main St, City: Springfield | Profile updates are saved and reflected on the profile page. |
UA-06 | View order history, including previous order details and status. | User: user1@example.com | Order history page displays with details of past orders. |
UA-07 | Initiate password reset for a registered email. | Email: user1@example.com | Password reset link is sent to the provided email. |
UA-08 | Log out from any page on the platform. | Logged in as user1@example.com | User is logged out and redirected to the login page. |
Product Catalog Functional Test Cases
Test Case ID | Test Case Description | Test Data | Expected Outcome |
---|---|---|---|
PC-01 | Browse books by selecting a specific genre from the catalog. | Genre: Mystery | Books related to the Mystery genre are displayed. |
PC-02 | Search for books using a keyword (e.g., title, author). | Search Keyword: “The Adventure” | Search results display relevant books matching the keyword. |
PC-03 | Apply filters (e.g., price, format) to narrow down book listings. | Filter: Price Range $10-$20, Format: Hardcover | Results display only books within the specified price range and format. |
PC-04 | View a book’s detail page (including description, author bio, reviews). | Book Title: “The Mystery of the Old Mansion” | Detailed information about the selected book is displayed. |
PC-05 | Add a book to the shopping cart from the catalog or detail page. | Book ID: 101, Title: “Secrets of the Jungle” | Book is added to the cart, and the cart count is updated. |
PC-06 | Remove a book from the shopping cart. | Book ID: 101, Title: “Secrets of the Jungle” | Book is removed from the cart, and the cart updates accordingly. |
PC-07 | Save a book for later instead of adding it to the cart. | Book ID: 105, Title: “Gardening for Beginners” | Book is saved in the ‘Save for Later’ section and accessible there. |
PC-08 | View personalized book recommendations based on browsing history or preferences. | User: user1@example.com, Browsing History: Science Fiction | Recommendations display relevant books based on user’s preferences. |
Prompt 3: Exporting Test Cases to Excel
Prompt: “Can you store these test cases as an Excel sheet?”
This prompt will create an Excel sheet with test cases, allowing easy review, modification, and import into test management tools.
Prompt 4: Formatting for Zephyr Import
Prompt: “Format test cases for Zephyr import.”
For Zephyr import, ensure that all test cases are on a single sheet with standardized fields such as Test Case ID, Summary, Test Data, Expected Result, and Priority.
Prompt 5 from testcase s to Teststeps
Prompt: “provide teststep combinations for the given testcases (fysical steps) UA-01 | Register a new user account with valid details (email, password, etc.).”
Test Case: UA-01 Description: Register a new user account with valid details (email, password, etc.)
Step No. Test Step Expected Outcome 1 Navigate to the homepage of the “Book Style” Online Bookstore. Homepage loads successfully. 2 Click on the “Register” or “Sign Up” button/link. Registration page/form loads. 3 Enter a valid email address in the “Email” field (e.g., user1@example.com). Email is accepted and no errors are displayed. 4 Enter a valid password in the “Password” field (e.g., Test@1234). Password is accepted, meeting complexity requirements. 5 Confirm the password by entering the same password in the “Confirm Password” field. Password confirmation is accepted and matches the original password. 6 Fill in any additional required fields (e.g., name, phone number). Additional fields are accepted, with no validation errors. 7 Click the “Register” or “Submit” button to submit the form. Form is submitted, and account creation request is processed. 8 Verify that a success message is displayed, confirming account creation. Success message appears, indicating registration completion. 9 Check the provided email for a confirmation email from the platform. Confirmation email is received in the inbox within a few minutes. 10 Click the link in the confirmation email to verify the email address. Account is verified, and the user is redirected to the login page or confirmation page.
Prompt 6: Performance Test Cases as a Markdown Definition
Prompt: “Assuming we have performance test requirements and we are using azure wiki, you can ask the prompt to store performance testing requirements, as markdown files for a clear and organized documentation format.”
this could look something like this!
Example Markdown Definition:
# Performance Test Cases for "Book Style" Online Bookstore Platform
---
## User Accounts Performance Test Cases
| **Test Case** | **Description** | **Expected Outcome / Benchmark** |
|-----------------------------|---------------------------------------------------------------------------------|------------------------------------------------------------------|
| **User Registration Load** | Measure time taken to complete user registration (new account creation) under load of 500 concurrent users. | Registration completes in ≤ 3 seconds, without server timeout. |
| **Login Response Time** | Test response time for logging in with different user credentials at peak load. | Login response time ≤ 2 seconds; no server errors or delays. |
| **Profile Update Load** | Test load and response time when users update personal information under peak load (500 concurrent users). | Updates save in ≤ 2 seconds, without timeout or data loss. |
| **Order History Retrieval** | Measure time to retrieve user order history with multiple items (10-50 orders) under high load. | History loads in ≤ 3 seconds, remaining consistent for all users. |
| **Session Management** | Test performance of maintaining user session across 1000 users simultaneously. | Sessions maintain stability without significant delays. |
| **Password Reset Speed** | Test time taken to initiate and complete password reset process at peak load. | Process completes in ≤ 5 seconds, with no email delivery delay. |
## Product Catalog Performance Test Cases
| **Test Case** | **Description** | **Expected Outcome / Benchmark** |
|---------------------------------|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| **Catalog Browsing Load** | Test load time for browsing catalog with 1000 items at peak load of 1000 concurrent users. | Catalog loads in ≤ 3 seconds with smooth scrolling, no lag. |
| **Search Query Response Time** | Measure response time for keyword searches with 500 concurrent users searching various terms. | Search results return in ≤ 2 seconds for all users. |
| **Product Filter Performance** | Test response time for applying filters (e.g., genre, price) in the catalog under high load. | Filter results display in ≤ 2 seconds without errors or delays. |
| **Book Detail Page Load** | Test time to load a book’s detail page with media (images, videos) at peak load. | Detail page loads in ≤ 2 seconds on desktop; ≤ 4 seconds on mobile. |
| **Recommendations Loading** | Test load time for displaying personalized book recommendations to 1000 concurrent users. | Recommendations appear within ≤ 2 seconds; no timeouts. |
| **Catalog Pagination Speed** | Measure performance of pagination when users move through large catalog sections (100+ pages). | Each page loads in ≤ 2 seconds with consistent performance. |
| **Inventory Update Load Test** | Test load and response time when sellers update book information or stock levels concurrently. | Updates save in ≤ 3 seconds, with no lag in reflecting updates. |
Using prompt refinement to generate and improve test cases can make testing efficient, comprehensive, and cost-effective. Storing test cases in multiple formats enhances flexibility for import into various test management tools. But do think further what you can do, you can generate performance testplans, strategies and whatever you want as long as you know how to prompt correctly
# Try It Yourself: Generating Effective Test Cases with Prompt Refinement
Follow these steps to practice generating different types of test cases using prompt refinement.
---
### Step 1: Generate Basic Functional Test Cases
Use this prompt to start with basic functional test cases for the User Accounts and Product Catalog features:
**Prompt**: "Create functional test cases for user accounts and the product catalog with a test case ID, description, and expected outcome."
---
### Step 2: Add Specific Test Data
Refine your prompt to include specific test data for each test case:
**Prompt**: "Add specific test data for each test case generated above."
---
### Step 3: Format for Performance Testing Requirements
Create performance test requirements using the following prompt:
**Prompt**: "Generate performance test cases for the User Accounts and Product Catalog sections of an online bookstore. Include load expectations and expected benchmarks."
---
### Step 4: Store as excel
Use a prompt to organize your generated performance test cases in a excel format:
**Prompt**: "Format the performance test cases above in excel, and save this file if possible for useage"