Getty Images/iStockphoto

Tip

Don't neglect API functional testing

APIs are how applications connect to a database, partner servers and integrated applications. Testing their efficacy is an essential QA task for every software team.

Applications rely on APIs to provide, retrieve and store data in the blink of an eye. That reliance makes testing APIs increasingly important.

In the recent past, developers would conduct unit tests on APIs during feature development. Beyond that stage, however, further API testing would be rare -- if it happened at all. With APIs becoming more prominent and the recognition of them as a potential source for intrusion, regular API testing has increased significantly. Currently, most test-savvy organizations execute API testing regularly as part of application functional testing.

This article looks at the necessary elements of a strong API functional testing strategy, the challenges of adoption and how to get started.

The challenges of functional testing on APIs

API testing ensures applications function as expected. It is an essential practice to properly manage security and error conditions, but functional testing of APIs is complicated. It requires technical know-how and the ability to dig deep and understand how applications process data. API testing is not testing that can occur by simply accessing a UI.

Key challenges involved in API testing include the following:

  • Access to a testing tool and training on how to use that tool.
  • Access to changing security tokens for testing.
  • Adequate API documentation.
  • Ability to fully test all dependencies.
  • Ability to fully test API sequencing calls.
  • Tracking of all APIs and ongoing changes.

Testing requires an understanding of API concepts, which are highly technical and difficult to explain. For those reasons, developers are often the ones responsible for testing API functionality. This responsibility reduces the time they spend creating new code. QA testers can handle API functional testing on an ongoing basis with proper training, a tool, API documentation and a support system so their questions can be answered.

To meet these challenges, a team should consider selecting an API testing tool and having a willing developer train QA staff how to test APIs. Start by ensuring all APIs have full documentation, including dependencies and sequencing information.

Consider having QA testers and IT staff develop a system where security tokens for APIs can be used without exposing unnecessary information. Many APIs require authorization tokens to exchange data. Other APIs may require security tokens to save or retrieve data. Security tokens change per use, so there's no option to set a single token code for ongoing testing executions. You need the IT team's cooperation to functionally test APIs in a secure fashion.

Next, make sure all API changes are tracked as stories or tasks. Functional testing depends on understanding any changes to API functionality so new tests can be developed to ensure test coverage. Many teams create an API inventory that enables them to track every API, its functions, and when it is updated or changed.

Understanding an application and the inner workings of the APIs it depends on is essential if you're going to achieve high-quality functional API testing.

Crucial elements of a comprehensive API functional testing strategy

For QA testers to succeed in API functional testing ,they need a test strategy. That strategy should include the following:

  • API documentation, including dependencies and sequencing.
  • Access to necessary security information for testing.
  • An API testing tool that assists in creating requests, reading responses and automating tests.
  • A dedicated test environment where APIs can be set up to function as close to production as possible.
  • Training on tool use specifically and API functionality generally.
  • A plan to execute API tests throughout the development lifecycle.
  • Time to correct defects.
  • A tool that assists testers in keeping test cases organized and easy to locate.
  • Time to analyze and plan API functional tests.

The only way to succeed with API functional testing is by making a true commitment to understanding the APIs and how they interact with each other and the application. By analyzing API documentation and input from development, QA testers can not only develop test cases, but also determine different API behaviors and create specific tests for them. Additionally, by fully understanding the API, tests can be prioritized and scheduled based on the effects they have on UX.

Get started with building a strategy for API functional testing

The first step to building a successful API functional testing strategy is to understand each API, its functions and its requirements. API requirements are often found within API documentation, but specific and necessary details are sometimes omitted.

Work with the API developers to ensure documentation includes the expected behavior under all scenarios, error conditions and status codes, the API's purpose and objective, and how the API affects the application workflow.

As a QA tester responsible for functional API testing, create a test plan and approach. Next, select an API testing tool that enables testers to create and execute both automated and manual tests. Many existing QA and developer tools include an option for API testing. Check the capabilities of your existing tools before adding another.

Next, create a test plan, and develop test cases. Once the test cases are created, organize them into all working combinations. One option is to create tests and then execute them. Or, within many tools, testers can quickly test as they go. In other words, you can be testing each request as you develop the test.

Once the testers become more familiar with API testing, identify API tests that can be automated. Choose tests for application-critical APIs to automate first. Most API testing tools contain easy-to-use options for the creation of automated API tests that the tester can schedule to execute as needed.

API functional testing is critical to ensure applications function accurately, securely and with superior performance. APIs are central to application development anytime an application saves, retrieves or shares data. APIs are coded and often changed either internally or may be adversely changed by external partners that use the API to connect. Testing APIs needs to be an ongoing test option to ensure application quality and a positive customer experience.

API testing comes with many challenges, but all can be overcome with an investment in time and adherence to best practices. Include API functional testing as a part of QA testing so that an application delivers what customers need and want.

Amy Reichert is a 20-plus-year professional QA tester and a QA lead, specializing in test development, execution and management techniques. Her experience comes from a variety of sources, including ERP systems, architectural design, e-commerce and healthcare software.

Dig Deeper on Software testing tools and techniques

Cloud Computing
App Architecture
ITOperations
TheServerSide.com
SearchAWS
Close