Skip to content
  • There are no suggestions because the search field is empty.

5 Ways ChatGPT Can Save Developers 100+ Hours of Testing Time (Prompts Included!)

Running a startup with a small team requires creativity to maximize productivity, prevent stress and keep the team energized. As the tech lead and founder at my startup, I’ve had to do just that.

The emergence of AI tools like ChatGPT has been a game-changer for us, allowing us to do more in less time without compromising on the quality of our products. One area where we've seen significant improvement is in our testing practices.

In this article, I’ll share with you some of the ways we’ve used ChatGPT to save countless hours of testing and how you can do the same. By the end of this article, you will have learned five ways to speed up your test processes, freeing you up to do other things you love.

We'll explore how you can streamline your testing process by using ChatGPT to Clean or Update Redundant Tests, Generate and Brainstorm Edge Cases, Create Mock and Fake Data, Automate UI Scripts, and Create a Test Document from Your User Stories.

Without further ado, let’s get into it!

 

2023-06-chatgpt-tile_tcm7-315735

 

Use ChatGPT to Clean or Update Redundant Tests

Agile testing emphasizes quick iteration, allowing for frequent changes to requirements and corresponding updates to features and tests. As a developer, rewriting tests might not feel like the most efficient use of your time, but trust me, it definitely is.


"Rewriting tests isn't a waste of time! Frequent changes to requirements and corresponding updates are a big part of Agile Testing."

With powerful language models like ChatGPT though, you don’t have to spend as much time managing tests anymore! You can ask ChatGPT to modify or update the tests to meet the new criteria by simply inputting your existing tests and the updated requirements.

Let's see how this could work.

Imagine you're working on a food delivery app's favourite feature, which allows users to save their preferred restaurants for easy access. You might already have a unit test like this:

import { getFavouriteRestaurants } from './favourites';

describe('Favourite Restaurants', () => {
it('should retrieve all favourite restaurants for a given user', async () => {
   // Mock user ID and expected favourite restaurants
   const userId = 123;
   const expectedFavourites = ['Restaurant1', 'Restaurant2', 'Restaurant3'];

   // Function to simulate adding to favourites
    expectedFavourites.forEach(restaurant => {
     addToFavourites(userId, restaurant);
   });

   // Retrieve the favourites and verify
   const favouriteRestaurants = await getFavouriteRestaurants(userId);
    expect(favouriteRestaurants).toEqual(expectedFavourites);
});
})

But your product owner just informed you that the feature requirements have changed. Users should now be able to sort their saved restaurants by name. Not to worry, you can use this prompt to save yourself the time and effort of modifying the tests.

 

Prompt

Updated Requirement: Users should be able to retrieve the list of favourite restaurants and also have the ability to sort the list using the name of the restaurant.

 Existing test: [existing test here]

 We have recently made updates to the requirements of the favourite feature on our food deliver app. I would like you to take a look at the existing test suite and update it to align with this updated requirement. Specifically, please ensure that the test suite now verifies the correct sorting of the favourite restaurants by name.

 Please ensure to maintain code quality and readability, adhering to our existing coding standards.

 

Use ChatGPT to Generate and Brainstorm Edge Cases


"You might have tested your app, but I will use it — in ways that you did not intend for it to be used.” - a user of the internet.

 

I’m convinced that every user thinks that way. No matter how much you prepare for edge cases, users always manage to find new ways to break your code. It's as if they have a personal vendetta against you.

Yes, we all know that catching every bug is impossible, but that doesn't make it any less frustrating when users come back with bug reports, especially when you invested a lot of time and effort into testing.

Fortunately, with the assistance of ChatGPT, you can make the process of brainstorming edge cases much more manageable. Here's a handy prompt that can guide you through the exploration of unforeseen scenarios using the example of our food delivery app.

 

Prompt

I am implementing a favourite feature in my food delivery app. The favourite feature gives users the ability to save their favourite restaurants and dishes for quick reordering.

I want you to suggest test cases for my test suite that would test my APIs. In the test suite, start with breaking cases, focusing on test cases that could break my code before writing tests that confirm the desired functionality.

 

ChatGPT Response

With a comprehensive list of potential edge cases at your fingertips, coming up with scenarios that align with your specific use case becomes a breeze. While it doesn't guarantee a bug-free product, it does offer peace of mind, knowing that you've saved substantial mental energy on test case generation.

 

Use ChatGPT to Create Mock and Fake Data

Creating mock data for unit or integration tests can be unnecessarily boring. You might run out of ideas after a number of John Doe and Jane Doe variations. But don't worry, ChatGPT can help! With a simple prompt, you can easily generate random fake data.

Here’s an example of a prompt that generates fake data for our food delivery app.

 

Prompt

Generate a sample user data for a food delivery app including fields like: full name, email, password, phone number, default delivery address (including street, city, state, and postal code), favorite dishes, last order details (like dishes ordered, restaurant, order date, and price), payment method details (like card type, last four digits, and expiry), and loyalty points. The data should be in a javascript object.

 

ChatGPT Response

You can even go a step further and ask GPT to implement a factory for you using a faker library. Here’s an example of a prompt that creates a mock data factory for a typescript project using faker-JS and Rosie libraries.

 

Prompt

I need a TypeScript code snippet for creating a user data factory of a food delivery app. The factory should use the rosie and faker libraries. The factory should be named UserFactory and it needs to generate the following fields fullName, email, password (which needs to be encrypted), phoneNumber, defaultDeliverAddress. Finally, demonstrate how to build a user object using the factory and print it.

 

ChatGPT Response

Imagine the time you'll save by combining these methods of creating fake data. Give it a try with any library or language you prefer. Just edit the prompt to suit your needs.GPT_response_fake_data_factory

 

Use ChatGPT to Automate UI Scripts

UI testing often gets neglected in small teams, especially when there isn't a dedicated tester or QA manager, and it's understandable.

If you’re a developer in a small team, you likely have a lot to build and changes to make, now you have to manage automation scripts in Selenium? It can be a lot to deal with, especially with deadlines to meet.

But with LLMs like ChatGPT, you can make UI testing less stressful. You can prompt ChatGPT to generate UI automation scripts in any framework of your choice.

Let me show you an example.

 

Prompt

Generate a Selenium script in nodejs that navigates to the homepage of my food delivery web app foodiedeliveries.com, checks if the page title contains 'Food Delivery', and then verifies the presence of a search bar and a 'Sign In' button.

 

ChatGPT Response

No more worries about incurring technical debt over UI tests. Spend more time building and less time updating your UI test scripts. Regression tests for your UI components have never been easier.

 

Use ChatGPT to Create a Test Document from your User Stories

A test document is a detailed record of the scope, testing approach, objectives, schedule, execution status, and outcomes for a software product. Although more utilized by testers and quality assurance managers, you can also benefit from creating a test document as a developer.

One of the main advantages of a test document is that it provides a clear scope of what needs to be tested, boosting confidence during releases. While it's unrealistic to catch every bug before a product is released, having a test document ensures that the most critical parts of the product are properly tested.

The good news is you don’t have to spend time learning the craft of a quality assurance manager to create one. With ChatGPT, you can create a decent test document if you already have a user story and acceptance criteria document.

Here’s an example prompt that uses a user story of the favourite feature of our food delivery app.

 

Prompt

Favourite Feature User story

As a FoodExpress user, I want to save my favorite restaurants, so that I can easily locate and reorder
from them in the future without having to search again.    

Acceptance Criteria
Users should be able to access the
"Favorite Restaurant" feature from the main menu or dashboard of the app.

- When browsing through restaurants, users should see an option (e.g., a star icon) next to each restaurant allowing them to mark it
as a favorite.
- Once a restaurant is marked
as a favorite, it should be added to the user's "Favorite Restaurant" list.
- Users should be able to view their "Favorite Restaurant" list from the main menu or dashboard.
- Users should have the option to remove a restaurant from their favorites list at any time.

This is the user story of the favourite feature on my food delivery app. Using the user story, craft a comprehensive test document detailing the testing scope, approach, objectives, and execution status of a product, leveraging its user story and acceptance criteria. The document aims to boost team confidence, ensuring vital product aspects have been tested, while also presenting a gauge for test coverage. Present the test document in a tabular format such that I can easily input the data in a bug tracking tool like JIRA

 

ChatGPT Response

Of course, your own test document would be more comprehensive than this.

By keeping track of your testing activities and test coverage, you'll be able to improve the quality of your product in the long run. So why not give it a try?

 

Challenges & Recommendations

Data Privacy & Compliance

By default, OpenAI uses the data you provide into their products, such as ChatGPT, to train and refine their models. This means that any sensitive information you input into ChatGPT could potentially be used to train their models, posing a risk to the confidentiality of that information.

To address this concern, you have the option to disable training in ChatGPT’s data control settings. This will prevent any conversations from being used for training purposes. However, If you want to be 100% safe, don’t share any sensitive information while using the product.

 

GPT-4 over GPT-3

Be cautious of ChatGPT's occasional inaccuracies or "hallucinations." These are instances where the model may provide information that is not entirely accurate or based on factual data.

ChatGPT relies on two models, GPT-3 and GPT-4, and while GPT-3 is faster, GPT-4 is smarter and tends to be more accurate. However, to access GPT-4, you will need to subscribe for $20 per month.

Nevertheless, regardless of the model you choose, verifying the information generated by any AI model through human review or other trusted verification methods is imperative.

 

Beware of the AI Trap

Guaranteed! These methods can save you hundreds of hours on testing — however, you have to be cautious. If you're not careful, you might end up wasting more time than if you hadn't used ChatGPT.

OpenAI constantly optimizes its models, which sometimes results in inconsistencies in the AI’s responses. This means that a prompt that works perfectly today may not produce the exact same result tomorrow. And if you’re seeking consistent results, you may find yourself spending extra time fine-tuning your prompt or engaging in lengthy conversations with the AI.

To tackle this issue, ChatGPT offers a feature called custom instructions. It allows you to provide additional context during your chats and specify how you want the AI assistant to respond.

By incorporating custom instructions, you can minimize inconsistencies in ChatGPT's responses and save valuable time that would have been spent on additional conversations.

 

Continue to Iterate

New AI tools continue to pop up every day. As they do, there’ll be more ways you can save time, enhance code quality and increase productivity. So, As you advance in your software development journey, constantly seek out new ways to refine your processes and make valuable contributions to your team. Keep iterating and never stop improving!



MagicPod is a no-code AI-driven test automation platform for testing mobile and web applications designed to speed up release cycles. Unlike traditional "record & playback" tools, MagicPod uses an AI self-healing mechanism. This means your test scripts are automatically updated when the application's UI changes, significantly reducing maintenance overhead and helping teams focus on development.


Jahdunsin Osho

Written by Jahdunsin Osho

Founder and Tech Lead at Edubaloo, is passionate about providing affordable quality education for students across Africa. Prior to this, he worked at several startups, building scalable backend systems, developing consumer blockchain applications and core blockchain infrastructures. Impact-driven, Jahdunsin leverages his non-technical skills in SEO, copywriting, and paid advertising to ensure that the products he builds reach the target audience.