AI in API Testing: How to Test Faster With ChatGPT

Rate this content
Bookmark

Start using AI at full power. Generate scenarios, write tests, and create test data faster with ChatGPT. The demonstration will be provided via Cypress tool.

FAQ

The main benefit of using artificial intelligence in API testing is to delegate monotonous and repetitive work to AI, allowing testers to focus on more complex aspects of testing and improving efficiency.

No, AI cannot fully replace human testers as it still requires human oversight for validation and to handle complex tasks that AI may not interpret correctly. AI serves as a useful assistant but not as a complete replacement.

Version 3.5 of the chat is free and primarily handles text inputs but is limited by outdated information since its last update was in January 2022. Version 4.0, a paid version, supports various file formats including PDFs, images, and videos, and is updated as of April 2023, making it more relevant.

AI can help in creating test cases by quickly generating numerous tests based on provided specifications, significantly reducing the time and effort required to write tests manually. This is especially useful when pressed for time and needing to cover many endpoints or scenarios.

The API testing strategy using AI includes checking specifications to ensure correct endpoint names and functionality, testing status codes, validating payload and response headers, and assessing basic performance to ensure efficient and secure API operations.

When using sensitive data with AI tools, it's crucial to ensure that such data is not exposed or misused. Data like usernames, passwords, and other personal information should be omitted or securely handled to prevent data breaches and ensure privacy.

Human oversight is essential when using AI-generated tests to verify the accuracy and relevance of the tests. This involves manually reviewing and possibly adjusting the AI-generated outputs to ensure they meet the specific requirements and standards of the project.

Olga describes starting API testing from scratch at Spleeky as a challenging process where she had to establish QA and QC processes, write test documentation, and implement necessary unit and end-to-end tests to cover all endpoints effectively.

Olga Trofimova
Olga Trofimova
26 min
07 Dec, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses the use of AI in API testing and provides a step-by-step strategy for incorporating artificial intelligence with chat.dpt. It emphasizes the importance of analyzing documentation and creating test cases using tools like Swagger and Cypress. The Talk also addresses the role of human involvement in testing, the balance between manual work and AI assistance, and the need for validation of AI-generated tests. Overall, AI can significantly speed up the testing process, but human analysis and vigilance are still necessary for accurate results.

1. Introduction to AI and API Testing

Short description:

Hi, everyone! Today, I'll share a step-by-step strategy for API testing and discuss how incorporating artificial intelligence with chat.dpt can elevate your testing process. Let's dive into the heart of the matter. API is an important layer in the application, and the chat can help us delegate monotonous work to AI. I joined Spleeky as the only QA and had to start everything from scratch. The chat was a popular tool, so I decided to experiment and give it a try. Let's focus on versions 3.5 and 4.2.0, as they have their pros and cons.

Hi, everyone, and thank you for joining me today. My name is Olga, and I am honored to be your guide in the intersection between artificial intelligence and API testing. So I believe that you will learn new tips and approach today.

Today, I'll share with you a strategy for API testing, step by step, and discuss why incorporating artificial intelligence, particularly with chat.dpt, can elevate your testing process to a new level. So in today's examples, we will learn and we will see how to use the chat for REST API and GraphQL.

But first, a bit about myself. My current position is QA manager at Spleeky. For most of my life, I worked with automation, built processes from scratch, and tried different test frameworks. Also, I'm a huge fan of life improvement. I love mountain climbing and so on. For example, last month I climbed on a height of 3,000 meters and the Alps. But at work, I love to ease, but not to complicate. So now let's dive into the heart of the matter.

API is one of the important layers in the application. It's very easy to understand why. It's important to cover. If we have a look at my conspire pyramids, here API tests are set at the integration level, which is supposed to be the second batch of our tests. So how can the chat help us at this stage? The main point is we can delegate monotonous and repetitive work to AI. Let me illustrate how things used to look in my company. I joined Spleeky this summer, and I was the only QA at the project. The team tested features on their own, but there were no QA or QC processes or test documentation, so I had to start everything from scratch. We had unit tests, but we also needed end-to-end tests and covered endpoints with API tests. At the time, we had 30 endpoints in REST and 20 in GraphQL. When you start from scratch, you are usually pressed for time. And I was looking for a popular and convenient tool for boosting my work. The chat was on everyone's lips, so I just decided to experiment and give it a try to find out whether it was worth it or not. And the chat has two versions, 3.5 and 4, but they also released version 4.2.0, but let's focus today just on the first two. Of course, all these have their pros and cons. Version 3.5 is free, but it takes just text. News makes mistakes.

2. Testing Strategy and Documentation Analysis

Short description:

The last update was in January 2022, and version 4.0 requires payment for premium features. However, it supports various file formats and can generate images. The testing strategy involves checking specifications and performing various steps, such as verifying status codes, payload, headers, and basic performance. Practice begins with analyzing the documentation using specific steps.

And the last update was in January 2022, which means that it doesn't have access to the newest information. And as for version 4.0, to unlock the premium features, you need to pay for it. That's the bad news.

But it takes not only text, but other files formats such as PDFs, tables, images, audio, videos, and archives. What's more, it can generate images itself. And as for the knowledge update, the last time was in April 2023. That means that this version is more relevant.

Now I'm going to go into the testing strategy. The testing strategy consists of two steps. First and foremost, we need to check specifications. We always need to start from this step. This is also important to be sure that endpoints are named correctly, that resources and their types depict the correct model, and there is no lack of duplicated functionality.

Then comes to testing itself. As for the testing, it can be broken down into several steps. Firstly, it's necessary to check the actuality of the status code. When you send, for example, a post request and create new item, you should get 201 status code. If we send a request which is forbidden, we expect 403 status code. Then check the payload. Check that the body JSON names, types, and fields are correct. Don't forget about requests with an error response. The third thing you need is check the headers of response. Headers are critical because they affect security and performance. The last step you need to do is check basic performance. In case the operation was a success but took a lot of time, the test is still considered failed.

Now, it's time for practice. Before I start, please keep in mind that it's not safe to share sensitive data. Always clear it. Let's start with the first stage, documentation. So create a prompt and ask the chat to analyse the documentation. For this purpose, we can use several steps.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Network Requests with Cypress
TestJS Summit 2021TestJS Summit 2021
33 min
Network Requests with Cypress
Top Content
Whether you're testing your UI or API, Cypress gives you all the tools needed to work with and manage network requests. This intermediate-level task demonstrates how to use the cy.request and cy.intercept commands to execute, spy on, and stub network requests while testing your application in the browser. Learn how the commands work as well as use cases for each, including best practices for testing and mocking your network requests.
Testing Pyramid Makes Little Sense, What We Can Use Instead
TestJS Summit 2021TestJS Summit 2021
38 min
Testing Pyramid Makes Little Sense, What We Can Use Instead
Top Content
Featured Video
Gleb Bahmutov
Roman Sandler
2 authors
The testing pyramid - the canonical shape of tests that defined what types of tests we need to write to make sure the app works - is ... obsolete. In this presentation, Roman Sandler and Gleb Bahmutov argue what the testing shape works better for today's web applications.
Full-Circle Testing With Cypress
TestJS Summit 2022TestJS Summit 2022
27 min
Full-Circle Testing With Cypress
Top Content
Cypress has taken the world by storm by brining an easy to use tool for end to end testing. It’s capabilities have proven to be be useful for creating stable tests for frontend applications. But end to end testing is just a small part of testing efforts. What about your API? What about your components? Well, in my talk I would like to show you how we can start with end-to-end tests, go deeper with component testing and then move up to testing our API, circ
Building a Voice-Enabled AI Assistant With Javascript
JSNation 2023JSNation 2023
21 min
Building a Voice-Enabled AI Assistant With Javascript
Top Content
In this talk, we'll build our own Jarvis using Web APIs and langchain. There will be live coding.
Test Effective Development
TestJS Summit 2021TestJS Summit 2021
31 min
Test Effective Development
Top Content
Developers want to sleep tight knowing they didn't break production. Companies want to be efficient in order to meet their customer needs faster and to gain competitive advantage sooner. We ALL want to be cost effective... or shall I say... TEST EFFECTIVE!But how do we do that?Are the "unit" and "integration" terminology serves us right?Or is it time for a change? When should we use either strategy to maximize our "test effectiveness"?In this talk I'll show you a brand new way to think about cost effective testing with new strategies and new testing terms!It’s time to go DEEPER!
Playwright Test Runner
TestJS Summit 2021TestJS Summit 2021
25 min
Playwright Test Runner
Top Content

Workshops on related topic

Designing Effective Tests With React Testing Library
React Summit 2023React Summit 2023
151 min
Designing Effective Tests With React Testing Library
Top Content
Featured Workshop
Josh Justice
Josh Justice
React Testing Library is a great framework for React component tests because there are a lot of questions it answers for you, so you don’t need to worry about those questions. But that doesn’t mean testing is easy. There are still a lot of questions you have to figure out for yourself: How many component tests should you write vs end-to-end tests or lower-level unit tests? How can you test a certain line of code that is tricky to test? And what in the world are you supposed to do about that persistent act() warning?
In this three-hour workshop we’ll introduce React Testing Library along with a mental model for how to think about designing your component tests. This mental model will help you see how to test each bit of logic, whether or not to mock dependencies, and will help improve the design of your components. You’ll walk away with the tools, techniques, and principles you need to implement low-cost, high-value component tests.
Table of contents- The different kinds of React application tests, and where component tests fit in- A mental model for thinking about the inputs and outputs of the components you test- Options for selecting DOM elements to verify and interact with them- The value of mocks and why they shouldn’t be avoided- The challenges with asynchrony in RTL tests and how to handle them
Prerequisites- Familiarity with building applications with React- Basic experience writing automated tests with Jest or another unit testing framework- You do not need any experience with React Testing Library- Machine setup: Node LTS, Yarn
AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
How to Start With Cypress
TestJS Summit 2022TestJS Summit 2022
146 min
How to Start With Cypress
Featured WorkshopFree
Filip Hric
Filip Hric
The web has evolved. Finally, testing has also. Cypress is a modern testing tool that answers the testing needs of modern web applications. It has been gaining a lot of traction in the last couple of years, gaining worldwide popularity. If you have been waiting to learn Cypress, wait no more! Filip Hric will guide you through the first steps on how to start using Cypress and set up a project on your own. The good news is, learning Cypress is incredibly easy. You'll write your first test in no time, and then you'll discover how to write a full end-to-end test for a modern web application. You'll learn the core concepts like retry-ability. Discover how to work and interact with your application and learn how to combine API and UI tests. Throughout this whole workshop, we will write code and do practical exercises. You will leave with a hands-on experience that you can translate to your own project.
Detox 101: How to write stable end-to-end tests for your React Native application
React Summit 2022React Summit 2022
117 min
Detox 101: How to write stable end-to-end tests for your React Native application
Top Content
WorkshopFree
Yevheniia Hlovatska
Yevheniia Hlovatska
Compared to unit testing, end-to-end testing aims to interact with your application just like a real user. And as we all know it can be pretty challenging. Especially when we talk about Mobile applications.
Tests rely on many conditions and are considered to be slow and flaky. On the other hand - end-to-end tests can give the greatest confidence that your app is working. And if done right - can become an amazing tool for boosting developer velocity.
Detox is a gray-box end-to-end testing framework for mobile apps. Developed by Wix to solve the problem of slowness and flakiness and used by React Native itself as its E2E testing tool.
Join me on this workshop to learn how to make your mobile end-to-end tests with Detox rock.
Prerequisites- iOS/Android: MacOS Catalina or newer- Android only: Linux- Install before the workshop
API Testing with Postman Workshop
TestJS Summit 2023TestJS Summit 2023
48 min
API Testing with Postman Workshop
Top Content
WorkshopFree
Pooja Mistry
Pooja Mistry
In the ever-evolving landscape of software development, ensuring the reliability and functionality of APIs has become paramount. "API Testing with Postman" is a comprehensive workshop designed to equip participants with the knowledge and skills needed to excel in API testing using Postman, a powerful tool widely adopted by professionals in the field. This workshop delves into the fundamentals of API testing, progresses to advanced testing techniques, and explores automation, performance testing, and multi-protocol support, providing attendees with a holistic understanding of API testing with Postman.
1. Welcome to Postman- Explaining the Postman User Interface (UI)2. Workspace and Collections Collaboration- Understanding Workspaces and their role in collaboration- Exploring the concept of Collections for organizing and executing API requests3. Introduction to API Testing- Covering the basics of API testing and its significance4. Variable Management- Managing environment, global, and collection variables- Utilizing scripting snippets for dynamic data5. Building Testing Workflows- Creating effective testing workflows for comprehensive testing- Utilizing the Collection Runner for test execution- Introduction to Postbot for automated testing6. Advanced Testing- Contract Testing for ensuring API contracts- Using Mock Servers for effective testing- Maximizing productivity with Collection/Workspace templates- Integration Testing and Regression Testing strategies7. Automation with Postman- Leveraging the Postman CLI for automation- Scheduled Runs for regular testing- Integrating Postman into CI/CD pipelines8. Performance Testing- Demonstrating performance testing capabilities (showing the desktop client)- Synchronizing tests with VS Code for streamlined development9. Exploring Advanced Features - Working with Multiple Protocols: GraphQL, gRPC, and more
Join us for this workshop to unlock the full potential of Postman for API testing, streamline your testing processes, and enhance the quality and reliability of your software. Whether you're a beginner or an experienced tester, this workshop will equip you with the skills needed to excel in API testing with Postman.
Working With OpenAI and Prompt Engineering for React Developers
React Advanced Conference 2023React Advanced Conference 2023
98 min
Working With OpenAI and Prompt Engineering for React Developers
Top Content
Workshop
Richard Moss
Richard Moss
In this workshop we'll take a tour of applied AI from the perspective of front end developers, zooming in on the emerging best practices when it comes to working with LLMs to build great products. This workshop is based on learnings from working with the OpenAI API from its debut last November to build out a working MVP which became PowerModeAI (A customer facing ideation and slide creation tool).
In the workshop they'll be a mix of presentation and hands on exercises to cover topics including:
- GPT fundamentals- Pitfalls of LLMs- Prompt engineering best practices and techniques- Using the playground effectively- Installing and configuring the OpenAI SDK- Approaches to working with the API and prompt management- Implementing the API to build an AI powered customer facing application- Fine tuning and embeddings- Emerging best practice on LLMOps