We are in an era where AI is going to be an important player of the software industry. However its too early to say that AI will completely replace QAs in near future. But it is imperative for us to understand that we(QAs) should be familiar with prompt engineering to be more productive in our work. For that reason, I started exploring ChatGPT’s various capabilities using different prompts for QA work to assist in my day to day responsibilities.
While I don’t heavily depend on its suggestions, I find it particularly handy for certain tasks. It proved to be a quick and helped me finishing a few things at much faster pace.
In this blog, I will be sharing some of my favourite ChatGPT prompts for QA, which I have saved in my notebook for regular use.
ChatGPT Prompts for QA
I believe ChatGPT can’t be much helpful for QAs as software testing needs holistic context and detailed understanding of the software application. ChatGPT may not be able to grasp the full context and intricacies of a specific software application or its interactions.
Relying solely on ChatGPT for generating test scenarios or cases might result in overlooking critical aspects that a human QA professional with domain knowledge would be able to address. ChatGPT can be supporting tool for QAs, assisting in certain aspects or providing insights but human experience remain essential for effective software testing.
Keeping above in mind, I use ChatGPT for certain tasks where detailed knowledge of my software is not necessary. For instance, when a developer makes a code change, such as refactoring a lengthy method into smaller ones, ChatGPT can be leveraged in verifying the modification. Additionally, it can suggest various unit tests to cover these alterations.
Similarly, when testing an address form, ChatGPT can be used for generation of diverse test data with minimal effort.
Here are a few tasks for which I find ChatGPT helpful and I have curated a list of prompts for QA:
- Test case generation for code change.
- Test data generation.
- Code review to discover potential issues.
- Code generation for test automation.
- Assisting me in documentation.
#1 – Prompt for QA to generate test cases for application code change
I would like you to act as an experienced QA with strong knowledge of coding and best practices of coding. I am seeking your support in generating test cases against a code change made in our application by a developer. In order to generate test cases please follow the below guidelines, if anything is still not clear to you, please clarify it before generating the test cases.
1. Generate test cases which covers both positive and negative scenarios. If needed please generate multiple test cases varied by test data to cover different positive and negative scenarios.
2. Make sure you generate test case which goes the error handing (catch block) of changed code. If there is no catch block in code, then suggest test cases which needs to be handled in catch block.
3. Suggest test cases covering non-functional aspects. For example, concurrency.
4. Make sure the test cases are relevant to given code and should not be designed based on your assumption.
5. Generate the test cases in tabular format.
When to use above prompt
Use the above prompt when you need support from ChatGPT to generate thorough test cases for a specific code change. This is beneficial during code reviews to ensure developer has added required tests covering for both positive and negative scenarios. By using this prompt, I am able to uncover a few potential edge cases, which enhances my testing.
When above prompt used for a code change as below:
function calculateDiscount(bin) {
// Visa range (5111 - 5222)
const visaPattern = /^5[1-2]\d{2}/;
// MasterCard range (4111 - 4444)
const masterCardPattern = /^4[1-4]\d{2}/;
if (visaPattern.test(bin)) {
return 15.0; // Visa discount
} else if (masterCardPattern.test(bin)) {
return 10.0; // MasterCard discount
} else {
return 0.0; // No discount for other card types
}
}
#2 – Prompt for code Review
I would like you to act as a QA (Software Tester) and would request you to follow the below guidelines to verify the correctness of a piece of code provided by me.
Objective: Verify the correctness the given code. Identify potential edge cases, handle exceptional scenarios, and ensure the code meets the specified requirements. Additionally suggest me a list of test cases which I should be verifying against the provided code. Here are the instructions to verify the code:
1. Code Understanding: Provide very high-level explanation and the purpose of code.
2. Input Validation: Test the code with various valid, invalid, naughty strings, unicode characters, etc to ensure the expected behaviour. Please highlight the input which is not handled gracefully by the code.
3. Boundary Cases: Test with minimum, maximum possible input value and relevant variables.
4. Exception Handling: Intentionally trigger exceptions and errors to confirm the effectiveness of exception handling.
5. Suggest if there is non-functional issue with the code, example check memory leakages, assess if code is suitable for multithreading.
6. Security Considerations: Check for basic security consideration and highlight if there is any potential vulnerabilities like SQL injection, cross-site scripting etc.
Additional Information:
– Suggest if there is any additional information, limitation or suggestion to improve the provided code.
– Suggest overall assessment of code and readability and maintainability.
– Suggest different test cases including edge cases which I should perform to assess the code change in detail.
Here is my piece of code: <provide-your-code-change>
When to use above prompt
I use the above prompt when I need support from ChatGPT to suggest improvement in code changed by developer. Using above prompt, I try to understand the code quality and based on the ChatGPT’s response, I see if anything can be improved. Additionally, it helps me uncovering issues like security vulnerabilities.
#3 – Test Data Generation Prompt
I am seeking your support in generating a comprehensive set of test data to thoroughly assess the input field’s resilience and functionality. Include variations in case sensitivity, testing inputs with both uppercase and lowercase characters (e.g., “TestInput” and “testinput”). Introduce leading and trailing whitespaces to evaluate the system’s handling of spaces around inputs (e.g., ” Input123 “). Test the input field with a mix of characters, including alphanumeric and special characters (e.g., “Input@123”). Explore numeric-only (e.g., “123456”) and alphabetic-only inputs (e.g., “AlphaString”). Assess the system’s behaviour with inputs at both the maximum and minimum allowed lengths. Test the input field’s response to an empty input and evaluate how it handles duplicate entries. Introduce naughty strings like (Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗), unicode characters, and Latin characters to assess the system’s security and internationalisation aspects. Include edge cases, such as null characters and potential injection attempts (e.g., “<script>alert(‘XSS’)</script>”).
Generate test data for input field <input-field> in tabular format.
When to use above prompt
Above prompt can be used to generate diverse set of test data.
Response from ChatGPT when above prompt was given for email input field.
Test Case | Input | Description |
---|---|---|
1 | test@example.com | Basic valid email format |
2 | Test@Example.com | Case sensitivity check (uppercase) |
3 | tEsT@eXaMpLe.CoM | Case sensitivity check (mixed case) |
4 | user123@domain.com | Alphanumeric characters |
5 | user.123@domain.com | Alphanumeric characters with a dot |
6 | user@123domain.com | Alphanumeric characters in the domain |
7 | user@domain.123 | Alphanumeric characters in the top-level domain |
8 | input@example.com | Leading whitespace |
9 | input@example.com | Trailing whitespace |
10 | Input123 | Numeric-only characters |
11 | AlphaString | Alphabetic-only characters |
12 | special@characters! | Special characters |
13 | 123456 | Numeric-only input at the minimum allowed length |
14 | A | Alphabetic-only input at the minimum allowed length |
15 | verylongemailaddress1234567890@domain.com | Maximum allowed length |
16 | Empty input | |
17 | test@example.com | Duplicate entry |
18 | Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗 | Naughty string with unicode characters |
19 | <script>alert(‘XSS’)</script> | Potential injection attempt (XSS) |
20 | user@exåmple.com | Latin characters with international characters |
21 | user@exámple.com | Unicode characters with international characters |
22 | user@domain..com | Double dot in the domain |
23 | user@domaincom | Missing dot in the domain |
24 | user@domain.c | Single character in the top-level domain |
25 | user@domain.com. | Trailing dot in the domain |
#4 – Code generation for test automation using ChatGPT
Below is a sample ChatGPT prompt for QA that I used to generate a code to give me future date. The purpose of sharing this prompt is to demonstrate its level of detail.
Write a utility function in Java to generate a future date from the current date. The function should take an input parameter, ‘numberOfDays’ (N), representing the number of days to be added to today’s date. The output should be a date string formatted as YYYY-DD-MM. Implement the function to accurately calculate the future date by adding the specified number of days to the current date. Ensure that the function handles edge cases appropriately and adheres to the specified date format.
#5 – Prompt for QA to assist in Documentation
Once again, the following ChatGPT prompt for QA serves as an illustrative example of how to write a detailed prompt for maximum assistance from ChatGPT. The specifics of your prompt may vary but it is important to have such level of detail in prompt. Explicitly specify each element of your expectations to enhance the relevance of response.
I am in need of your assistance in designing an organized Excel sheet outline that I intend to share with various teams within my company. Our company operates an e-commerce website, and we’ve recently introduced a feature that offers discounts based on the basket value. To thoroughly test this feature, collaboration among different teams is essential for end-to-end testing. The document’s purpose is to systematically record the test cases executed by different teams, their corresponding results, any open defects, and essential artefacts such as screenshots. Could you please design a comprehensive spreadsheet format that facilitates seamless sharing among teams? The goal is to create a structured and user-friendly template for tracking the testing process and outcomes.
Read why Selenium with Jmeter is not the best choice for client side performance testing.
To receive such insightful articles directly to your inbox, subscribe my newsletter.
Thank you for reading this post, don't forget to subscribe!