Testing APIs is crucial. It helps identify errors in the code, improve code quality, and empowers developers to make changes more quickly with confidence that they haven’t broken existing behavior. Automation and Artificial Intelligence can have a significant impact on API testing. Utilizing automation in API testing can be found in many products, but the majority of companies have yet to tap into the potential that AI and machine learning can have on enhancing testing. At IBM, we believe there are a few key capabilities to keep an eye on as the future of API testing incorporates more AI and automation.

Adding Intelligence to Automation

With basic automated testing, a developer might use code that generates random inputs for each field. A lot of those tests will end up being wasted as they are repetitive, or don’t match the business use of the application. In those cases, manually written tests are more valuable because the developer has a better understanding of the API usage.
Adding intelligence provides a great opportunity to enhance automated testing to work with business logic – i.e. users will place an item in their online shopping cart before they are taken to the page that requires an address, so testing an API with an address but no items is a waste of time. Intelligent automated testing could generate a dynamic set of input values that make sense, and are a broader test of the API’s design with more confident results.

Semantic and Syntactic Awareness

Creating new API test cases can be time-consuming when done manually. Generating tests can accelerate this, but developers can only rely on this if the generated tests are high quality.
One way to improve the quality of generated tests is semantic and syntactic awareness – that is, training an intelligent algorithm to understand key business or domain entities such as a ‘customer’, ’email’, or ‘invoice’ – and how to generate data from them. By pointing it at existing tests, APIs and business rules, it should be able to ‘learn’ from that and become better at generating tests with less developer input later on.. 

Automating Setup and Teardown

A tester’s workload can be significantly decreased by identifying and automating routine tasks. Using an algorithm to look at an API specification and see what the dependencies are allows the machine to conduct routine setup and teardown tasks. For example, if a bookshop has an API for orders, the AI can set up the scaffolding and create the prerequisites for the test. If a tester needs to create a book and a customer prior to creating an order, those tasks are conducted by the AI, and then cleaned up and deleted after the test. As an algorithm learns about the company’s API structures, it can generate more of the setup and teardown tasks.

Mining real world data

The effectiveness of API testing is greatly increased when tests use realistic data, representative of real-world production conditions. Generating tests from production data must be done with care due to the risk of exposing sensitive data. Without automation, creating real-world useful tests is difficult to achieve at scale because of the high labor cost of combing through mounds of data, determining what is relevant, and cleansing the data of sensitive values.

Using AI to identify gaps in test coverage

A recent addition to the IBM Cloud Pak for Integration Test and Monitor uses AI to analyse the API workloads in both production and test environments, identifying the ways that APIs are being invoked in each. This analysis allows it to identify real-world production API scenarios that aren’t adequately recreated in the existing test suite, and automatically generate tests that fill that gap. 
Allowing an algorithm to efficiently examine millions of production API calls means that production personnel only need to review and approve the smartly generated tests. This is a very effective way of increasing test coverage in a way that will have the most impact – as it prioritizes closing testing gaps based on how users are interacting with APIs in the real world.
To learn more about how you could benefit from AI and automation developments in your API testing, download a free trial of IBM Clouk Pak for Integration today.

More from Analytics

How data stores and governance impact your AI initiatives

6 min read - Organizations with a firm grasp on how, where, and when to use artificial intelligence (AI) can take advantage of any number of AI-based capabilities such as: Content generation Task automation Code creation Large-scale classification Summarization of dense and/or complex documents Information extraction IT security optimization Be it healthcare, hospitality, finance, or manufacturing, the beneficial use cases of AI are virtually limitless in every industry. But the implementation of AI is only one piece of the puzzle. The tasks behind efficient,…

IBM and ESPN use AI models built with watsonx to transform fantasy football data into insight

4 min read - If you play fantasy football, you are no stranger to data-driven decision-making. Every week during football season, an estimated 60 million Americans pore over player statistics, point projections and trade proposals, looking for those elusive insights to guide their roster decisions and lead them to victory. But numbers only tell half the story. For the past seven years, ESPN has worked closely with IBM to help tell the whole tale. And this year, ESPN Fantasy Football is using AI models…

Data science vs data analytics: Unpacking the differences

5 min read - Though you may encounter the terms “data science” and “data analytics” being used interchangeably in conversations or online, they refer to two distinctly different concepts. Data science is an area of expertise that combines many disciplines such as mathematics, computer science, software engineering and statistics. It focuses on data collection and management of large-scale structured and unstructured data for various academic and business applications. Meanwhile, data analytics is the act of examining datasets to extract value and find answers to…

Financial planning & budgeting: Navigating the Budgeting Paradox

5 min read - Budgeting, an essential pillar of financial planning for organizations, often presents a unique dilemma known as the “Budgeting Paradox.” Ideally, a budget should give the most accurate and timely idea of anticipated revenues and expenses. However, the traditional budgeting process, in its pursuit of precision and consensus, can take several months. By the time the budget is finalized and approved, it might already be outdated.In today's rapid pace of change and unpredictability, the conventional budgeting process is coming under scrutiny.It's…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters