10x Smarter Testing with AI

Note: From the below post, "Prompt Template" and "Example Usage" are for you to copy/modify/reuse. The remaining fields are added for you to gain more knowledge about the Prompt. Happy learning!

Any Functionality | Generate test cases using provided examples | Test Case Generation | Few-Shot Prompt

Purpose
Any Functionality | Generate test cases using provided examples | Test Case Generation | Few-Shot Prompt

QE Category

Prompt Type
Few-Shot

Typical SUTs and Quality Phases
Ideal for refining and expanding test cases during iterative test design or user story grooming.

Prompt Template

Role: A QA engineer tasked with generating test cases for [Feature Description] based on the user story below and the provided examples.

Context:
- **User Story**: [Insert User Story]
- **Acceptance Criteria**: [List Criteria]
- **Priority**: High/Medium/Low

Examples:
1. **Test Case ID**: TC-001
- **Title**: Validate file upload with correct format.
- **Preconditions**: User is logged into the application.
- **Steps**:
1. Navigate to the file upload page.
2. Select a valid CSV file.
3. Click the 'Upload' button.
- **Expected Results**: File is uploaded successfully, and a confirmation message is displayed.

2. **Test Case ID**: TC-002
- **Title**: Reject unsupported file format during upload.
- **Preconditions**: User is logged into the application.
- **Steps**:
1. Navigate to the file upload page.
2. Select an unsupported file format (e.g., .exe file).
3. Click the 'Upload' button.
- **Expected Results**: File is not uploaded, and an error message is displayed.

Task:
Generate at least 5 additional test cases, ensuring:
1. They adhere to the format used in the examples.
2. Include test cases for edge conditions and error handling.

Example Usage

Role: A QA engineer tasked with generating test cases for a dynamic pricing feature in a SaaS platform.

Context:
- **User Story**: As a product manager, I want to dynamically adjust pricing based on user location and demand to maximize revenue.
- **Acceptance Criteria**:
- Pricing should adjust within 1 second of location change.
- Discounts must apply correctly based on promotional campaigns.
- Invalid or incomplete location data must default to a base price.
- **Priority**: High

Examples:
1. **Test Case ID**: TC-001
- **Title**: Validate pricing adjustment for a valid location change.
- **Preconditions**: User is on the pricing page.
- **Steps**:
1. Enter a valid location in the 'Location' field.
2. Observe the displayed pricing.
- **Expected Results**: Pricing updates correctly within 1 second based on the new location.

2. **Test Case ID**: TC-002
- **Title**: Validate default pricing for incomplete location data.
- **Preconditions**: User is on the pricing page.
- **Steps**:
1. Enter incomplete location data (e.g., country only).
2. Observe the displayed pricing.
- **Expected Results**: Default pricing is displayed.

Task:
Generate at least 5 additional test cases, ensuring:
1. They adhere to the format used in the examples.
2. Include test cases for edge conditions and error handling.

Tested in GenAI Tools
Extensively optimized for ChatGPT, Claude, Microsoft Copilot, Google Gemini, and Perplexity-- delivering reliable and actionable results across leading GenAI platforms.

Customized Prompt Engineering Techniques

  1. Replace the examples with ones closely aligned to your system under test.
  2. Use placeholders for functionality-specific details to maintain adaptability.
  3. Iteratively refine examples to better guide test case generation.

Value of the Prompt
This prompt builds on provided examples, allowing for faster and more targeted test case generation.

Tips and Best Practices

  1. Ensure the examples represent varied scenarios (e.g., positive, negative, and edge cases).
  2. Iterate within the same GenAI tool to refine the examples dynamically.
  3. Leverage complementary tools to validate and cross-check test cases.

Hands-On Exercise
Use the examples provided to generate additional test cases for a resource allocation feature. Experiment with edge scenarios like limited resources or high demand.

Appendix and Additional Information

  1. Further Reading: 'Lessons Learned in Software Testing' by Cem Kaner, James Bach, and Bret Pettichord-- a guide to effective test design.
  2. Additional Learning: Practice generating test cases for workflows that include dependencies or third-party integrations.

Want More?
Expand the examples to include more complex scenarios and watch how the tool adapts to generate targeted test cases. Experiment with edge cases to challenge system behavior.

Author
Ashwin Palaparthi

[kkstarratings]
Share on...
LinkedIn
Reddit
WhatsApp
Email

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.

Thank you for subscribing!

Check your inbox to confirm your subscription to Ai4Testers™. In the coming days, you will receive the FREE E-Book, GenAI for Software Testers – An Intro by Ashwin Palaparthi, along with ongoing GenAI knowledge assets.