How can Gen AI Improve Test Coverage?

 As we know Generative AI is a category of AI that can create text, images, video, audio or code based on the prompt given by the user to perform a specific task. Given its wide application and usage, the main underlying question is how can we use GenAI in the field of software testing?

There are multiple use cases on the application of GenAI capabilities in the field of software testing. On this article I have focused on very important use case of improving test coverage using GenAI.

§  Can GenAI be used to understand a software requirements/User Story?

§  Can GenAI be used to generate test cases for the given requirement?

§  Can GenAI improve the test coverage?

For this study, I have used ChatGPT 3.5 as GenAI platform. I tested this platform by providing a simple User story and prompting ChatGPT to understand the requirement and generate test cases.

Steps performed:

1.      Prompted ChatGPT to act like/play the role of a Software Test Engineer (user prompt 1)

2.      Prompted ChatGPT to list the various points we need to consider while understanding / analysing a given requirement (user prompt 2)

3.      Prompted ChatCPT to generate test cases based on a sample user story (user prompt 3)

4.      Gave the same user Story and again asked to generate test cases to see how it can improve generated test cases over previous results (user prompt 4)

5.      Prompted ChatGPT to consolidate the previous results and give me the final list of test cases (user prompt 5)

 

Key findings:

§  GenAI has wide range of use cases when prompted to act like a Software Test Engineer (Requirement understanding, Test planning, Test Case Design, Test Execution…etc.,) [Refer the below response for user prompt 1].

§  GenAI has ability to perform detailed analysis of a given software requirement. The areas listed by ChatGPT shows in-depth and extensive understanding/analysis covering various aspects (acceptance criteria, user roles, dependencies, functional requirements, non-functional requirements, business rules, data requirements, error handling, performance exceptions, security, integration points, scalability, regulatory/compliance requirements…etc.,) [Refer the below response for user prompt 2].

§  GenAI can generate detailed test cases and improve its results over previous results generations. [Refer the below response for user prompt 3 & 4].

§  GenAI has ability to think out-of-box scenarios even when the requirement is ambiguous and with unclear acceptance criteria (Note: sample user story provided to ChatGPT is very simple requirement but has unclear acceptance criteria and missing explicit conditions)

§  Final generations of test cases for the given requirement shows improved test coverage (covering all positive/intended flows, negative/alternative flows, exceptions). [Refer the below response for user prompt 5].

§  I have tested this same example with few experienced test engineers in my team and surprisingly found testers were not able to think 100% of the test cases generated by ChatGPT.  The main reason for this is due to ChatGPT’s well-structured thoughtful requirement analysis and ability to learn & improve over previous results.

§  I strongly believe GenAI can play key role in helping test engineers to generate test cases in quick time with extensive test coverage.

Note: I have used very simple prompts for simplicity of this study and ChatGPT has ability to provide improved accurate results based on the good user prompts (clear context, specific details, reference to previous results, clear expectations)

User Prompt 1: Act like a Software Test Engineer

Response:

Sure, I can provide information and guidance on how a software test engineer typically approaches their job:

1.      Understanding Requirements: As a software test engineer, one of the first steps is to thoroughly understand the software requirements and specifications. This involves collaborating with product managers, developers, and other stakeholders to ensure a clear understanding of what the software is supposed to do.

2.      Test Planning: Create a detailed test plan that outlines the scope, objectives, test cases, and testing strategies for the project. This plan serves as a roadmap for the testing process.

3.      Test Case Design: Design test cases based on the requirements. Test cases should cover different scenarios, including normal and edge cases, to ensure comprehensive testing.

4.      Test Environment Setup: Prepare the necessary test environments, including hardware, software, and data, to replicate the production environment as closely as possible.

5.      Test Execution: Execute test cases according to the test plan. This involves interacting with the software, entering test data, and observing the system's behavior. Automated testing tools may be used to streamline this process.

6.      Defect Identification: When issues or defects are found, document them clearly. Provide detailed information, including steps to reproduce the issue, expected vs. actual results, and any relevant logs or error messages.

7.      Regression Testing: After defects are fixed, perform regression testing to ensure that the changes do not introduce new issues and that the existing functionality still works as expected.

8.      Performance Testing: Conduct performance testing to assess the software's scalability, responsiveness, and resource utilization under various load conditions.

9.      Security Testing: Assess the software's security by identifying vulnerabilities and weaknesses, such as SQL injection, cross-site scripting (XSS), and authentication issues.

10.  Test Reporting: Generate test reports that summarize the testing activities, including the number of test cases executed, defects found, and the overall quality of the software.

11.  Collaboration: Maintain open communication with the development team to address issues promptly and ensure a smooth testing process.

12.  Continuous Learning: Stay updated with the latest testing techniques, tools, and industry trends to improve testing processes and effectiveness.

13.  Automation: Explore opportunities for test automation to increase testing efficiency and repeatability, especially for regression testing.

14.  Adaptability: Be flexible and adaptable, as software development methodologies, project requirements, and technologies may change over time.

15.  Quality Assurance: Ultimately, the goal is to ensure the software meets high-quality standards and is ready for release to users.

Remember that the role of a software test engineer is crucial in delivering a reliable and bug-free software product to end-users. Effective testing helps identify and resolve issues early in the development cycle, saving time and resources in the long run.

 

User Prompt 2: Can you list down various points to consider while analyzing the requirements of a given user story

Response:

Certainly, analyzing the requirements of a given user story is a critical step in software development. Here are various points to consider during this analysis:

1.      User Story Description: Understand the user story's title and narrative description to get a high-level overview of what the user wants.

2.      Acceptance Criteria: Review the acceptance criteria, which outline the specific conditions that must be met for the user story to be considered complete. These criteria provide detailed requirements.

3.      Functional Requirements: Identify the functional requirements, which describe what the system or feature should do. Look for actions, operations, or behaviors that need to be implemented.

4.      Non-Functional Requirements: Consider non-functional requirements, such as performance, security, usability, scalability, and reliability. These criteria define how the system should perform rather than what it should do.

5.      Dependencies: Check if there are any dependencies on other user stories, features, or components that need to be considered when implementing this user story.

6.      Business Rules: Understand any business rules or logic that apply to the user story. These rules may dictate specific workflows, calculations, or data validations.

7.      Data Requirements: Determine what data the user story interacts with, whether it involves creating, updating, or retrieving data. Understand the data sources and data structures involved.

8.      User Roles: Identify the user roles or personas involved in the user story. Understand how each user role interacts with the system and what their specific needs are.

9.      User Interface (UI) Considerations: If applicable, analyze the UI requirements. Look for design elements, layout, and user interactions needed to fulfill the user story.

10.  Error Handling: Consider how the system should handle errors or exceptions. Define error messages, recovery processes, and error logging requirements.

11.  Performance Expectations: Determine any performance expectations, such as response times, load handling, and resource utilization. Ensure that the system meets performance requirements.

12.  Security Requirements: Assess security considerations, including user authentication, data encryption, access control, and protection against common vulnerabilities.

13.  Integration Points: Identify any external systems, APIs, or services that the user story needs to interact with. Specify how data will be exchanged and any integration requirements.

14.  Scalability and Extensibility: Consider whether the feature needs to scale to accommodate future growth or if it should be easily extensible to add new functionality later.

15.  Regulatory and Compliance Requirements: Determine if there are any legal or regulatory requirements that the system must adhere to, such as GDPR, HIPAA, or industry-specific standards.

16.  User Experience (UX) Guidelines: If applicable, follow UX guidelines and best practices to ensure that the user story aligns with a consistent and user-friendly design.

17.  Testing Scenarios: Think about various test scenarios that can be derived from the requirements to ensure comprehensive testing. Consider both positive and negative test cases.

18.  Edge Cases: Identify edge cases and exceptional scenarios that may not be covered in the acceptance criteria but could impact the user's experience.

19.  Performance Metrics: Define specific performance metrics and key performance indicators (KPIs) that will be used to measure the success of the user story.

20.  Feedback Mechanisms: Determine how user feedback will be collected and incorporated into the user story's implementation and future iterations.

21.  Documentation Requirements: Specify any documentation that needs to be created, such as user manuals, technical documentation, or training materials.

22.  Constraints: Consider any constraints or limitations, such as budget, timeline, or technology stack, that may impact the implementation of the user story.

23.  Priority: Understand the priority of the user story within the overall project or product backlog.

24.  Acceptance Test Plan: Develop an acceptance test plan that outlines the steps and criteria for validating that the user story meets its requirements.

25.  Traceability: Ensure that there is traceability between the user story, its acceptance criteria, and any related documents, such as design specifications or architectural diagrams.

By thoroughly analyzing these aspects of a user story, you can ensure that the requirements are well-understood and can be effectively implemented by the development team. This analysis sets the stage for successful software development and helps avoid misunderstandings and scope creep.

 

User Prompt 3: Generate test cases for the following user story, "The CSR agent should be able to transfer the online chat discussion to another agent"

Response:

Certainly, here are some test cases for the user story "The CSR agent should be able to transfer the online chat discussion to another agent":

Test Case 1: Successful Transfer

  • Test Case ID: TC001
  • Test Scenario: The CSR agent initiates a chat transfer to another agent successfully.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. The system validates and confirms the transfer.
    4. The chat is transferred to the specified agent.
  • Expected Result: The chat is successfully transferred to the specified agent, and the CSR agent is no longer part of the conversation.

Test Case 2: Invalid Agent Name

  • Test Case ID: TC002
  • Test Scenario: The CSR agent attempts to transfer the chat to an agent with an invalid or non-existent name.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters an invalid or non-existent agent name.
    3. The system attempts to process the transfer.
  • Expected Result: The system should display an error message indicating that the specified agent does not exist or is invalid. The chat remains with the CSR agent.

Test Case 3: Transfer Cancelation

  • Test Case ID: TC003
  • Test Scenario: The CSR agent initiates a chat transfer but decides to cancel it.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. Before confirming, the CSR agent selects the option to cancel the transfer.
  • Expected Result: The system should cancel the transfer process, and the chat remains with the original CSR agent.

Test Case 4: Transfer Confirmation

  • Test Case ID: TC004
  • Test Scenario: The CSR agent initiates a chat transfer and is required to confirm the transfer.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. The system prompts the CSR agent to confirm the transfer.
    4. The CSR agent confirms the transfer.
  • Expected Result: The chat is successfully transferred to the specified agent after the CSR agent confirms the transfer.

Test Case 5: Transfer Timeout

  • Test Case ID: TC005
  • Test Scenario: The CSR agent initiates a chat transfer, but the transfer process times out.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. The system does not confirm the transfer within a reasonable time frame.
  • Expected Result: The system should time out the transfer process and notify the CSR agent. The chat remains with the original CSR agent.

These test cases cover various scenarios to ensure that the chat transfer feature functions correctly and handles both successful and unsuccessful transfers appropriately.

 

User Prompt 4: Generate test cases for the following user story, "The CSR agent should be able to transfer the online chat discussion to another agent"

 

Certainly, here are some test cases for the user story "The CSR agent should be able to transfer the online chat discussion to another agent":

Test Case 1: Successful Chat Transfer

  • Test Case ID: TC001
  • Test Scenario: The CSR agent successfully transfers an ongoing chat discussion to another agent.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of the target agent.
    3. The system validates the target agent's availability.
    4. The CSR agent confirms the transfer.
  • Expected Result: The chat discussion is seamlessly transferred to the specified agent, and both agents can communicate with the customer.

Test Case 2: Invalid Agent for Transfer

  • Test Case ID: TC002
  • Test Scenario: The CSR agent attempts to transfer the chat to an agent who is unavailable or does not exist.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of an agent who is unavailable or doesn't exist.
    3. The system attempts to process the transfer.
  • Expected Result: The system should display an error message indicating that the specified agent is unavailable or invalid, and the chat remains with the CSR agent.

Test Case 3: Transfer Confirmation Prompt

  • Test Case ID: TC003
  • Test Scenario: The CSR agent initiates a chat transfer and is prompted to confirm the action.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of the target agent.
    3. The system prompts the CSR agent to confirm the transfer.
    4. The CSR agent confirms the transfer.
  • Expected Result: The chat is successfully transferred to the specified agent after the CSR agent confirms the transfer.

Test Case 4: Chat Transfer Timeout

  • Test Case ID: TC004
  • Test Scenario: The CSR agent initiates a chat transfer, but the transfer process times out.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of the target agent.
    3. The system does not confirm or complete the transfer within a specified timeout period.
  • Expected Result: The system should time out the transfer process, notify the CSR agent, and keep the chat with the original CSR agent.

These test cases cover various scenarios to ensure that the chat transfer feature functions correctly and handles both successful and unsuccessful transfers appropriately.

 

User Prompt 5: can you consolidate all the other test cases that are generated in previous regenerations and list the complete list of test cases

Response:

Certainly, here are all the test cases, including those generated in previous responses:

Test Case 1: Successful Chat Transfer

  • Test Case ID: TC001
  • Test Scenario: The CSR agent successfully transfers an ongoing chat discussion to another agent.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of the target agent.
    3. The system validates the target agent's availability.
    4. The CSR agent confirms the transfer.
  • Expected Result: The chat discussion is seamlessly transferred to the specified agent, and both agents can communicate with the customer.

Test Case 2: Invalid Agent for Transfer

  • Test Case ID: TC002
  • Test Scenario: The CSR agent attempts to transfer the chat to an agent who is unavailable or does not exist.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of an agent who is unavailable or doesn't exist.
    3. The system attempts to process the transfer.
  • Expected Result: The system should display an error message indicating that the specified agent is unavailable or invalid, and the chat remains with the CSR agent.

Test Case 3: Transfer Confirmation Prompt

  • Test Case ID: TC003
  • Test Scenario: The CSR agent initiates a chat transfer and is prompted to confirm the action.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of the target agent.
    3. The system prompts the CSR agent to confirm the transfer.
    4. The CSR agent confirms the transfer.
  • Expected Result: The chat is successfully transferred to the specified agent after the CSR agent confirms the transfer.

Test Case 4: Chat Transfer Timeout

  • Test Case ID: TC004
  • Test Scenario: The CSR agent initiates a chat transfer, but the transfer process times out.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is in progress.
  • Test Steps:
    1. The CSR agent selects the "Transfer Chat" option.
    2. The CSR agent enters the name or ID of the target agent.
    3. The system does not confirm or complete the transfer within a specified timeout period.
  • Expected Result: The system should time out the transfer process, notify the CSR agent, and keep the chat with the original CSR agent.

Test Case 5: Successful Transfer

  • Test Case ID: TC005
  • Test Scenario: The CSR agent initiates a chat transfer to another agent successfully.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. The system validates and confirms the transfer.
    4. The chat is transferred to the specified agent.
  • Expected Result: The chat is successfully transferred to the specified agent, and the CSR agent is no longer part of the conversation.

Test Case 6: Invalid Agent Name

  • Test Case ID: TC006
  • Test Scenario: The CSR agent attempts to transfer the chat to an agent with an invalid or non-existent name.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters an invalid or non-existent agent name.
    3. The system attempts to process the transfer.
  • Expected Result: The system should display an error message indicating that the specified agent does not exist or is invalid. The chat remains with the CSR agent.

Test Case 7: Transfer Cancelation

  • Test Case ID: TC007
  • Test Scenario: The CSR agent initiates a chat transfer but decides to cancel it.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. Before confirming, the CSR agent selects the option to cancel the transfer.
  • Expected Result: The system should cancel the transfer process, and the chat remains with the original CSR agent.

Test Case 8: Transfer Confirmation

  • Test Case ID: TC008
  • Test Scenario: The CSR agent initiates a chat transfer and is required to confirm the transfer.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. The system prompts the CSR agent to confirm the transfer.
    4. The CSR agent confirms the transfer.
  • Expected Result: The chat is successfully transferred to the specified agent after the CSR agent confirms the transfer.

Test Case 9: Transfer Timeout

  • Test Case ID: TC009
  • Test Scenario: The CSR agent initiates a chat transfer, but the transfer process times out.
  • Preconditions:
    1. CSR agent is logged in.
    2. An online chat discussion is ongoing.
  • Test Steps:
    1. The CSR agent selects the option to transfer the chat.
    2. The CSR agent enters the name or identifier of the agent to whom they want to transfer the chat.
    3. The system does not confirm or complete the transfer within a specified timeout period.
  • Expected Result: The system should time out the transfer process, notify the CSR agent, and keep the chat with the original CSR agent.

These test cases cover various scenarios to ensure that the chat transfer feature functions correctly and handles both successful and unsuccessful transfers appropriately.