All About API Testing

APIs are the unsung hero of our connected world

We live in an exciting age of intelligence, where progress moves at the speed of imagination. We are connected to the world and one another like never before. API (Application Programming Interface) is the unsung hero of our connected world. Here’s everything you need to know to about APIs and how API testing is play a vital role.

What is an API?

APIs are used to integrate systems together. You can make data available for other systems to access via API or accept data from other systems. This is how different devices and applications talk to each other and share information.

Successful companies like Facebook, YouTube, and Twitter use APIs so that their application can communicate with third party programs. Usually API work similarly to the way any website works. A request is made from the client to the server and we get the response over the http protocol.

The best analogy can be a waiter in a restaurant. The Waiter takes the request (which is the order for food) from the customers and conveys it to the kitchen (which is our server) and gets the food (response) from the kitchen to the customers. APIs do the exact same thing. An API is the messenger that takes your request and tells the systems what to do and then returns the response back to you.

What is API Testing?

API testing is a type of software testing that involves testing application programming interfaces (APIs) directly and as part of integration testing to determine if they meet expectations for functionality, reliability, performance, and security. Since APIs lack a GUI, API testing is performed at the business layer. During the API testing, the data is exchanged from XML or JSON through HTTP requests and responses. These are technology independent and will work with a variety of the programming languages and technologies.

3 Reasons we need API Testing

1. Testing the Application Early and Without a User Interface

The later you find defects, the more expensive they are to fix. API testing engages testers early in development lifecycle. With API testing you can start testing your application early even without a UI. This helps to identify and fix issues early in development lifecycle which would otherwise be expensive to fix when identified during GUI testing. The advantage of API testing is that a lot of logic can be validated without being dependent upon the UI.

2. To Come up with an Awesome Test Automation Strategy and Reduce the Costs

If we understand the “Automation pyramid” we can come up with an effective automation strategy.

The test pyramid concept was developed by Mike Cohn and has been described in his book “Succeeding with Agile.” The base of the pyramid are the Unit Tests, these are the tests that are executed against the code. Unit tests are the least expensive to create; they are the fastest to execute and yield highest results. The 2nd layer are the API tests which are executed against the service layer. Finally, at the top of the pyramid are the UI tests that actually validates the application as a whole at presentation layer.

As we move up the pyramid, the cost involved in the creation and maintenance of tests, the test execution time, test fragility and test coverage keeps increasing. The automation pyramid preaches that you should do much more automated testing through unit tests and API tests than you should through GUI based testing. Agile’s success is hugely dependent on early feedback. During practices like continuous integration the amount of time the GUI regression tests take to provide feedback when new build is deployed is too long. UI tests are expensive to develop and maintain. A small change in UI can break the tests and lead to a lot of rework.

Several times the testers are forced to automate at UI layer. However, the tests end up being unreliable, expensive, slow and flaky. This is one of the reasons why many companies fail at efforts to implement an effective automation strategy.

3. Agile Software Development and Reduced Manual Regression Testing

According to a recent survey by VersionOne, 95% of the respondents said their organizations practice agile. Agile methodologies are no longer solely the domain of startups and small development shops. The main reasons for adopting agile over the traditional methodologies is to accelerate product delivery and to embrace the changes. Agile has also increased the frequency with which applications are released, which in turn has created an increased demand for new ways to quickly test them. Test automation has become a critical factor to maintain agility. So it is necessary for agile teams increase their level of API testing while decreasing their reliance on GUI testing. API testing is recommended for the vast majority of test automation efforts.

API automation can drastically reduce the pressure of regression testing from the QA team. By integrating the API automated tests to the build server, the QA team can provide a quick feedback on the health of the application as soon as it is deployed. This provides an early evaluation of its overall build strength before running GUI tests. API test automation requires you to code less and provides faster test results and better test coverage. APIs get stabilized early and are unlike to change frequently like the user interface. GUI tests can’t sufficiently verify functional paths and back-end APIs/services associated with multi-tier architectures. APIs are always the most stable interface to the system under test.

API testing is a unique form of software testing, and is particularly valuable for the businesses that embrace a continuous integration process. Building API tests during development of any software or service has far-reaching benefits across teams, all the way down to how your customer experiences the product. Making software that your target audience will love is essential to the success of your business and by having your APIs tested rigorously and regularly, you will ensure a reliable way of achieving it.

Postman is a Google Chrome app that helps you create, save, send HTTP requests and test the response data. It helps to automate the process of making API requests and testing API responses, allowing testers to establish a very efficient workflow. Most programmers and testers are familiar with Postman. However, many use it just to check the response for the services that they are working on. They are unaware of the powerful features that postman offers like: Collections, Tests and Pre-request scripts. In this article, I would like to give a quick overview of the test snippets provided by Postman.

The main reason I like Postman is because of its powerful automation capabilities. Moreover, the learning curve for using it is very low and the app provides a very clean and intuitive user interface to test your server requests. These tests will validate every single time if the response is correct. Writing tests in Postman is made easy by JavaScript and inbuilt snippets, allowing any inexperienced tester to write an efficient test.

Postman is a real time saver making it easier for developers to develop and test APIs. Postman drastically reduces the pressure of regression testing from the QA team. API automated tests are far less time consuming than UI automated tests. The major advantage of API automation is that we can access the application without a user interface. This provides an early evaluation of its overall build strength before running GUI tests.

By integrating the API automated tests to the build server, the QA team can provide a quick feedback on the health of the application as soon as it is deployed. This is achievable with Newman, a command-line collection runner for Postman. It allows you to easily run a Postman collection directly from the command-line, and integrate it with your continuous integration server.

Prashant Hegde is a passionate tester. He has ably led test teams to success in many organizations and helped them improve their application quality process. Prashant is an agile enthusiast and has worked in different roles on agile teams for the last five ten years. Prashant enjoys sharing his experiences by blogging and participating in agile communities around the world. Prashant is a Certified Scrum master and frequent speaker at industry conferences. Prashant has helped thousands of ISTQB aspirants to clear their certifications with his free app ISTQB test mentor. Follow Prashant: Blog, Website, Linkedin, and Twitter.

Prashant Hegde
Prashant is a passionate tester. He currently works as a QA lead in Razorthink software. He leads a small team and ensures that the products he works on meet the highest standards in tight schedules and deadlines. Prashant is a gamer, a biker, and a writer. He writes a blog on best practices in software testing in his spare time.

The Related Post

An approach to secure maintainability and scalability for API testing projects One of the most important tasks in API testing is designing the input data whose quantum could explode due to the combination of a vast number of arguments. An experienced tester will inevitably figure out the advantages of the pairwise method in efficiently picking ...
APIs are subtly altering our expectations that there should be an app for everything. The concept of disruption has been given regal status across businesses, startups, and tech circles in recent years. With such great emphasis placed on change, user experiences are inevitably facing evolution as well. Application programming interfaces or APIs have great transformative powers to disrupt business, but are ...
An API provides much of the functional capabilities in complex software systems. Most customers are accustomed to interacting with a graphical user interface on the computer. But, many do not realize that much of the functionality of a program comes from APIs in the operating system or the program’s dynamic-link libraries (DLL).
An overview of web service testing solutions for traditional or non-technical testers. Much has been written on the technical execution of API tests, yet there are gaps in the details of what tests to design and how to design them. The articles tend to either get too technical too fast, or are too vague and ...
These are the popular authentication methods in TestArchitect Authentication in API testing is usually a complicated subject for both developers and testers since it requires extensive knowledge on various types of security protocols and encryption algorithms.
Social APIs are omnipresent and create special cases for testing. If you understand API testing, especially web service type APIs, testing social APIs is easy to grasp. The use of social APIs makes them a special case. They are omnipresent and very well understood. What this means is you need to have a good understanding ...
Lack of information and access to information isn’t an issue with web services. Web service documentation is widely available. Overview     One of the major persistent complaints from people who test is lack of information and lack of access to information. Luckily this is not the case with web services. If in the rare case with ...
API: An application programming interface (API) is a set of routines, protocols, and tools for building software applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types. An API defines functionalities that are independent of their respective implementations, which allows definitions and implementations to vary without compromising the interface. Source:
Here are some books you might find useful when developing your web services API testing strategy. The Art of Application Performance Testing by Ian Molyneaux — This book was just released and I found it an outstanding conceptual overview of performance testing a web based application. The book does a great job of reviewing the ...
Summary Remember that Agile is not an SDLC. Neither are Scrum and XP for that matter. Instead, these are frameworks for projects; they are built from practices (for example, XP has 12 core practices). Scrum and XP advocates will freely recommend that you pick a few practices to implement, then keep what works and discard ...
A case-study using: Java, REST Assured, Postman, Tracks, Curl and HTTP Proxies This is the first book review I have written on my site. So of course I had to choose a great book that was relevant to my niche. Alan Richardson’s book on Automating & Testing a REST API fits the bill perfectly. I am a big ...

Stay in the loop with the lastest
software testing news