API Testing Guide
API Testing Guide
Related Reading
Article from Professional Tester Magazine
Meeting the Challenge of API Testing
2
The Challenges of API Testing
Your inclination may be to extend the same principals of UI testing to APIshave developers build a UI in front of each API and put your
eyes on the glass, using manual testing to input spreadsheets of data and watch the response. This approach, however, is not ideal,
takes too long and will not scale. These challenges are exacerbated for several reasons:
3
The Challenges of API Testing, Continued
APIs pull data from multiple APIs, microservices and Versioning is a further cause
back-end systems. The resulting architecture can look of growing complexity in API True Valid
False
Versions
like the roots of a tree spreading out deep and wide. And testing. Most systems have a
its unreasonable to think you will have access to every degree of deprecation, so an API Master
Master
environment on this tree. Certain dependencies may still must be able to handle an old API Versions API Versions
{Clone1}
be under development, while third-party systems and version calling new versions, or MV3 MV1 MV2 MV3 MV1 MV2
mainframes may be too costly to test or their window and a combination thereof. The API Customer
API Versions
Customer
API Versions
{Clone1}
scope of access too limited. The simulation of unavailable must recognize missing values CV1 CV2 CV3 CV1 CV2 CV3
resources is then key to avoiding testing bottlenecks. But and assign some kind of default Order
proving too problematic. For instance, stubs and mocks are Whats more, it might be the OV3 OV2 OV1 OV3 OV2 OV1
usually written by developers, occasionally shared with QAs case that some versions can Item
API Versions
Item
API Versions
therefore be tested.
4
A Model for API Testing Transformation
To overcome these challenges, you need to adopt a modern approach and set of tools that will enable you to automate
API tests and incorporate them into a continuous delivery cycle.
Generate API tests Edit and extend Use one test and Run unlimited
automatically and in API tests without one tool across all layers tests with
multiple ways writing code and systems service virtualization
High-volume test automation requires test models, test-data generators and automatic oracles. Modelling, simulation, analytics,
visualization and tool-supported decision making will become important capabilities of test architects and testing teams.
Testers will have to learn how to create better test models and how to use them with more technical modelling and simulation tools.1
Related Reading
How Will the Internet of Things Affect Testers?
Industry Analyst Report: Gartner Market Guide for API Testing and Service Virtualization
5
Generate API Tests
Automatically and in
Multiple Ways
In a perfect world, you could automatically derive all of the test cases you need to
ensure adequate coverage, and then generate relevant test scripts while automatically
provisioning the appropriate sets of data to run against those tests. Thanks to advances
in testing technology, this ideal is not far off. But some degree of manual intervention is
going to be required. Therefore, the question is: How do you minimize this requirement?
70%
Leverage test data management technology to pull and mask existing data from
multiple back-end systems and, when needed, extract missing data synthetically for
maximum test coverage.
of all testing is still manual.2
6
Edit and Extend API Tests Without Writing Code
Automated tests created with scripts are dependent on the system under test. Should APIs change, as they are known to do, automated
tests may no longer work with future versions of the API, thus requiring additional scripting. In the end, this process may lead to large,
unmanageable sets of code that are prone to defects. At the same time, modern applications are complicated and tests need to be validated
across multiple application layers. This requires a much higher degree of test orchestration.
But with the right test automation tools and testing framework, you can edit and extend API tests without modifying a single line of code.
Look for an API testing solution that allows for modularity to facilitate reusability from release to release. Configuration (environment, IPs,
logins/passwords) should be stored separate from data, which should also be separate from invocation method (protocols such as web
services, MQ, JMS, TIBCO, SQL, etc). Being able to change one of these areas separate from the other two will allow you to reuse the tests
and adjust to the rapidly changing API landscape.
Choose an API testing solution with Selenium-based web UI testing and a native visual editor. With such tools, you can load tests
developed in Selenium UI and scale them across multiple browsers.
Related Reading
Automated Testing: Coping with Change
7
Use One Test and One Tool
Across All Layers and Systems
Tests need to work harder for you. One test should not only trigger and Full-stack, Automated and Scriptless API Testing
validate individual API calls and associated responses but also allow for
non-functional testing and work with open-source technologies like Selenium.
Mobile UI/HTTP
To do this, you need an extensible testing framework that enables your teams
End-to-End
to test modern Restful, SOA and ESBs along with more traditional protocols Functional Test
like JMS, MQ, Java and databases. It also requires collaboration between
systems, designers and implementers to tie test cases together to validate
a business process from end-to-end. Performance
Test
Use the output from one test as the input for subsequent tests. Integration
Test
Gain access to a rich feature set to facilitate collaboration of testing
assets and data between developers and analysts, along with a powerful Mainframe Database SAP Custom App
framework to invoke and verify requests across different services.
With CA Application Test, testers can use a single tool to test APIs, UIs and the
Stitch together test cases into workflows to mimic full business processes. layers that feed them.
1
Reuse existing functional tests as performance tests.
2015
CA.
ALL
RIGHTS
RESERVED.
Related Reading
The Price of Failure
8
Run Unlimited Tests With Service Virtualization
Service virtualization is the practice of simulating the behavior, data and performance characteristics of a dependent system that you can
then use at all stages of development and testing. In contrast to stubs and mocks, virtual services are created by recording actual services by
contract or by sample requests and responses. They are more dynamic and dont require a developer to write them.
Using service virtualization, you can test for a virtually unlimited set of test cases and scenarios whenever you want. You can set up tests to
verify all independent services and endpointsnot each in a vacuum, but all together. That is, you can simultaneously test the API that fetches
inventory data, the shopping cart API and so on, as the customer will use them. Service virtualization frees you from call limits so you can keep
testing and testing and testing until your app is completely debugged.
In fact, access to a virtualized API is actually better than the real thing for the simple reason that you can test all kinds of scenariosvarying
levels of functionality, performance and maintenance levelswith a virtualized service that you never could with an API. You can make the
virtualized API behave any way you want.
Create virtual copies of systems that can be Increase test flexibility velocity
used to test various scenarios on demand. Use virtual APIs for by driving headless tests.
rigorous testing.
Virtual service
9
A Fully Integrated, End-to-End API Solution
API testing is complex. An automated approach is needed to introduce the required rigor needed to support scalable testing frameworks that can
keep up with the rate of change. CA delivers the tools your teams need to develop, manage and test APIs simultaneously.
CA Agile Requirements Designer is an automated modeling solution enabling you to adapt to changing API requirements and designs. It
allows you to identify what tests to run with the proper number of use cases, and only in areas of application change. This allows you to maximize
test coverage without over testing.
When an API specification changes or test cases are updated, CA Agile Requirements Designer can quickly update virtual data to retain maximum
coverage. When a new variable is added to the flowchart, its exact impact on the data model is identified automatically. Any new combinations of
variables needed for 100-percent coverage can be created using CA Test Data Manager, while any broken or invalid combinations will be removed or
repaired. This eliminates the time wasted on manual data maintenance, providing your testers with the up-to-date data and environments needed
to rigorously test APIs.
Related Reading
Rigorously Test Composite Applications Faster with CA Test Data Manager and CA Agile Requirements
10
A Fully Integrated, End-to-End API Solution
CA Application Test is a multiprotocol testing platform, which supports web services, message queue technologies and
other endpoints such as file endpoints, file transfer endpoints and databases. With CA Application Test, you can:
Execute comprehensive test coverage: Cover REST, JSON and SOAP along with a variety of messaging interfaces and other endpoints
such as databases, flat files, EJBs, etc.
Easily create and manage API tests: Use a graphical visualizer for JSON-based payloads and path generation or an easy-to-use wizard
for generating web service API test cases.
Collaborate with high-productivity visual tests: Test headless middle tiers with no UIs.
Customize load testing: Set up parameters, test REST and other services and run hundreds of simulations at once.
With CA Application Test, testers can use a single tool to test UIs, APIs and the implementation layers that feed them. Users can model
a single test case with steps that invoke and verify an APIs behavior and performance, as well as validate database calls, SOAP messages
and many more types of transactions.
11
A Fully Integrated,
End-to-End API Solution
CA Service Virtualization and
CA API Management Suite
Together, CA Service Virtualization and CA API Management accelerate
CA commissioned Forrester Consulting to conduct a
application delivery providing solutions across the Plan, Build and Run phases of the
Total Economic Impact (TEI) study and examine the
application and service lifecycle.
potential ROI enterprises may realize by deploying
The CA API Developer Portal gives developers the ability to discover virtual CA Service Virtualization. Forrester interviewed four
services through a directory, improving the consumption of externally available organizations that had implemented this solution
services. Services and APIs can now be discovered faster and with in their enterprise. Taken as a whole, this composite
better documentation to plan development. company reported:5
12
To learn more, visit:
http://www.ca.com/us/products/develop-test.html
CA Technologies (NASDAQ: CA) creates software that fuels transformation for companies and enables them to seize the
opportunities of the application economy. Software is at the heart of every business, in every industry. From planning to
development to management and security, CA is working with companies worldwide to change the way we live, transact and
communicateacross mobile, private and public cloud, distributed and mainframe environments. Learn more at ca.com.
1
Gerrard Consulting sponsored by CA Technologies, How Will the Internet of Things Affect Testers? June 2016, http://www.ca.com/content/dam/ca/us/files/white-
paper/how-will-the-internet-of-things-affect-testers.pdf
2
Bloor Research, Automated Test Case Generation, September 2014, https://www.ca.com/us/collateral/industry-analyst-report/bloor-research-spotlight-paper-
automated-test-case-generation.register.html
3
Forrester, Forrester WaveTM: Modern Application Functional Test Automation Tools, Q2, 2015, April 17, 2015, https://www.forrester.com/report/The+Forrester+Wave+
Modern+Application+Functional+Test+Automation+Tools+Q2+2015/-/E-RES115627
4
IT Central Station, CA Service Virtualization Review (Real User: Sam Detweiler), March 15, 2016, https://www.itcentralstation.com/product_reviews/ca-service-
virtualization-review-36610-by-sam-detweiler
5
A Forrester Total Economic ImpactTM study commissioned by CA Technologies, The Total Economic ImpactTM of CA Technologies Service Virtualization, December 2015,
http://www.ca.com/content/dam/ca/us/files/industry-analyst-report/the-total-economic-impact-of-ca-service-virtualization.pdf
Copyright 2016 CA, Inc. All rights reserved. Microsoft and Internet Explorer are either registered trademarks or trademarks of Microsoft Corporation in the United States
and/or other countries. Java and all Java-based trademarks and logos are trademarks of Oracle Corporation in the United States, other countries, or both. All other
trademarks referenced herein belong to their respective companies. This document does not contain any warranties and is provided for informational purposes only.
Any functionality descriptions may be unique to the customers depicted herein and actual product performance may vary.
CS200-227595