Software Testing Class

Simple Guide to Learn API Testing?

What is API?

API stands for Application Programmable interfaces. API has an underlying collection of software application modules where each module serves the specific function. It accepts a set of input parameters and returns the desired result as output. APIs are generally platform independent so that they can be made available in the cross-platform environment. In order to understand this in simple language, consider a banking application that needs the secure data across multiple applications in cross platforms, instead of using multiple applications to make their separate calls to this database, these calls are made through single API which has multiple functions with different input parameters to serve the desired lookup request.

 

What is API Testing?

API testing specialized attributes which are distinct from other kinds of common software testing interfaces as follows:

API Architecture knowledge: To test an API, the tester should know what he is going to test which can be made clear after going through the architecture documents thoroughly. One should have the knowledge of the environment that API requires, OS it uses, hardware specifications it demands and its system requirements for smooth operation. This knowledge is very essential before testing could be initiated for an API.

Sound Programming skills: To test an API, the tester should have sound programming knowledge so that he can go through the API code and help the developer in code reviews and understand the underlying workflow among functions within API. This will help in identifying bugs as the tester has the knowledge of the internal behavior of an API. This is where white box testing serves the purpose.

 

API Testing

 

Functional Testing and Test Automation: An API is useful only if it serves the functional purpose for which it is developed for, therefore it demands black box testing or functional testing. As discussed before, API can be considered as a black box which accepts input parameters and responds with the desired output, therefore test cases covering all the functional aspects of the API should be designed and in order to avoid manual effort, it should be well automated. There are various testing tools available in the market like FitNesse, QTP, TestNG, etc. which could be used to automate the functional test cases. Automation saves the regression effort for subsequent release of the API.

Documentation and paperwork: Like SRS document is an essential document for any project development, in the similar way FRD (Functional Requirement Document) is required before API can be developed. FRD covers every possible detail about each and every function and procedure present in the API like a number of input parameters that function accepts, output object or parameter, input parameters type, output parameters type, boundary values, etc. FRD helps the tester to write the functional test cases to cover both positive and negative test scenarios which could be either manually tested for automated for regression test.

Integration and System testing: Just testing the API is not enough. It should be tested after integration with other software applications that it is well compatible and there are no surprises. Usually, such system testing is done in collaboration with the different testing team which requires lots of coordination and good communication skills.

Performance Testing: An API is used by multiple application, therefore, performance testing is required to test on the volume of requests it can handle with acceptable latency. Load and reliability testing are required to mark the threshold point and hence it decides on the number of application that this API can serve at a time.

Project Deadline: As discussed above, API testing is not very common and it involves within itself different kinds of testing, therefore it consumes lots of testing time and demands an effective project management which should not compromise on the project resources and its quality.

 

Advantages of using API:

1) Single gateway for multiple requests across many platforms.

2) Easy to add on new function within API on top of existing functions to serve a new purpose.

3) Handling changes within the API are very simple, instead of implementing those changes in multiple applications individually it could be done at one place within API.

4) API follows the standard input and output procedure of call which could be local or remote.

5) It is platform independent thus easy to use in multiple applications in cross platforms easily.

6) Building an API is an investment for future software within an organization as it encourages reusability.

 

API Testing Best Practices:

 

Example on API Testing:

So far we have discussed API and how its testing is different from another common software testing like GUI testing, web testing, etc. Now, we are going to discuss various points and guidelines which are required to be taken care of while testing API.

Input and Output Parameters:

String retrieveBankLocation (String CUSIP, String productType, Integer FirmCode, String currency);

In the above example, the test should cover below points:

 

Boundary Values:

 

Mandatory values:

 

Sequence or Order of API Call:

 

String getBankAccountNumber (retrieveBankLocation (String CUSIP, String productType, Integer FirmCode, String currency), String LegacyCode);

 

 

Difference between API Testing and Unit Testing:

API testing Unit Testing
The API testing perform by Testing team The API testing perform by Development team
The End to end functionality scenario is tested in API testing. Individual modules are tested in Unit testing.
This is Black box testing where QA do not have access to the source code This is White box testing where developer do have access to the source code
This is mainly focused on API functionality and no UI testing involved. Along with this testing, UI is also involved.
The all functionality around specific API is tested. The basic functionality of a specific Unit is tested.
The scope of this testing is also limited to specific API functionality with the broader area to cover. The scope of this testing is limited to a specific Unit we test.
This is executed on QA environment after the code is check-in and build is created. This is executed on DEV environment before the code is check-in.

 

Tools for API testing:

Few Open Source API Testing Tools For REST & SOAP Services:

 

 

Conclusion:

In this article, we discussed about API testing and explained it with the help of suitable example.

 

Exit mobile version