1. What is an API?
API (Application Programming Interface) is a software intermediary that enables two applications to communicate with each other. HTTP-based API is often called a Web API since they are used to access Web Applications which are deployed to Servers accessible over the Internet or network. Applications that are accessed via HTTP APIs are often called Web Services.
Mobile Applications often use Web Services and REST APIs to communicate with servers to implement their functionality. The Mobile Application processes the message returned from the Web Service and displays it to the User in the application GUI. So again, the user is unaware that HTTP requests are being made or of the format of the requests and responses.
___________________________________________________________________________
2. Define API TESTING with its types ,examples and some common advantages?
API Testing- It is a kind of software testing to determines and check if the developed APIs meet expectations regarding the functionality, reliability, performance, and security of the application or not
Common protocols that are testing in API testing are -HTTP, JMS, REST, SOAP, UDDI
Types-Validation Testing, Functional Testing, UI testing, Load testing, Runtime/ Error Detection, Security testing, Penetration testing, Fuzz testin, Interoperability testing
Example of API Testing:
Twitter: The API for Twitter is usually in two categories, one for accessing data and the other for interacting with the Twitter search.
YouTube: This API used for YouTube includes various functionalities including videos, live streaming, player, etc.
Google Maps API: These are designed mainly for mobile and desktop use with the help of a flash interface and JavaScript.
Amazon Advertising API: Amazon is known for their products and thus their advertising API accesses their product to discover their functionality and thus advertise accordingly
ADVANTAGES of API Testing:
Compatibility and easy integration with GUI: Simple integration would allow new user accounts to be created within the application before a GUI test started.
Language-Independent: In API testing, data is exchanged using XML or JSON. These transfer modes are completely language-independent that allows users to select any coding language while adopting automation testing services for the project.
Time Effective: In comparison to functional GUI testing API testing usually is less time-consuming. The web elements in GUI testing must be polled, which makes the testing process slower. Particularly, API test automation requires less code so it can provide better and faster test coverage compared to GUI test automation.
Test for Core Functionality: API testing provides the ability to access to the application without a user interface. The core and code-level of functionalities of the application will be tested and evaluated early before the GUI tests. This helps in detecting the minor issues which can become bigger during the GUI testing
______________________________________________________________________________
3. What are the main differences between API and Web Service?
Main differences are given below:
a) All web services are APIs but not all APIs are web services.
b) A web service uses only three styles of use: SOAP, REST, and XML-RPC for communication whereas API may be exposed to in multiple ways.
c) A web service always needs a network to operate while APIs don’t need a network for operation.
d) Web services might not contain all the specifications and cannot perform all the tasks that APIs would perform.
______________________________________________________________________________
4. What are the differences between API Testing and UI Testing?
API enables the communication between two separate software systems. A software system implementing an API contains functions or subroutines that can be executed by another software system.
On the other hand, UI ( User Interface) testing refers to testing graphical interface such as how users interact with the applications, testing application elements like fonts, images, layouts, etc. UI testing basically focuses on the look and feel of an application.
______________________________________________________________________________
5. What are the principles of an API test design?
Basically, there are five most important principles of an API test design:
Setup: Create objects, start services, initialize data, etc
Execution: Steps to apply API or the scenario, including logging
Verification: Oracles to evaluate the result of the execution
Reporting: Pass, failed or blocked
Clean up: Pre-test state
______________________________________________________________________________
6. What is the procedure to perform API testing?
a) Create the suite to add the API test case
b) Create the test development mode
c) Demand the development of test cases for the required API methods
d) Configure the control parameters of the application and then test conditions
e) Configure method validation
f) Arrange all API test cases
g) Execute the API test
h) Check test reports
______________________________________________________________________________
7. What must be checked when performing API testing?
a) Accuracy of data
b) Non-functional testing like performance and security testing
c) Implementation of response timeout
d) Schema validation
f) HTTP status codes
g) Data type, validations, order, and completeness
h) Authorization checks
I) Error codes in case API returns
______________________________________________________________________________
8. What are tools could be used for API testing?
A few common tools are Katalon Studio, Postman, SoapUi Pro, Apigee, automated API testing using REST Assured and CURL etc.
______________________________________________________________________________
9. What are the types of Bugs API testing can find?
a) Missing or duplicate functionality
b) Stress
c) Reliability
d) Security
e) Performance
f) Unused flags
g) Not implemented errors
h) Inconsistent error handling
I) Improper errors
j) Fails to handle error conditions gracefully
k) Multi-threading issues
______________________________________________________________________________
10. Difference API and Unit Testing?
API is owned by QA team where as Unit testing is owned by the development team
API is mostly black box testing where as Unit testing is white box testing
Full functionality of the system is considered in API testing as it will be used by the end-user (external developers who will use your API )where as Unit testing is done to verify whether each unit in isolation performs as expected or not
API test are often run after the build is ready and authors do not have access to the source code where as For each of their module, the developers are expected to build unit tests for each of their code modules and have to ensure that each module pass unit test before the code is included in a build.
______________________________________________________________________________
11. What are the main challenges of API testing?
1) Parameter Selection
2) Parameter Combination
3) Call sequencing
______________________________________________________________________________
12. What are API documentation templates that are commonly used?
There are several available API documentation templates help to make the entire process simple and straightforward.
- API blueprint
- RestDoc
- Web service API specification
- Swagger
- Miredot
- Slate
- FlatDoc
______________________________________________________________________________
13. Explain what is an HTTP request?
Hypertext Transfer Protocol is a way of sending messages to software on another computer over the internet or over a network.
An HTTP request is sent to a specific URL and consists of:
A) A VERB specifying the type of request e.g. GET, POST, PUT, DELETE
B) A set of HTTP Headers. The headers specify information such as the type of browser, type of content in the message, and what type of response is accepted in return.
C) A body, or payload in the request, representing the information sent to, or from, the Web Application. Not all HTTP messages can have payloads: POST and PUT can have payloads, GET and DELETE do not.
______________________________________________________________________________
14. What is a URL?
URL is a Uniform Resource Locator and is the address we use to access websites and web applications. When working with APIs you will often see this referred to as a URI (Uniform Resource Identifier). We can think of a URI as the generic name for a URL. When we have to call an HTTP API we need the URL for the endpoint we want to call Example-
https://www.thetravel.com/10-best-indian-foods/
This is the locator that says “I want to call the “10 best indian foods” resource located at “thetravel.com” using the http protocol”.
The above URL can be broken down into the form:
scheme://host/resource
• scheme-HTTP
• host-thetravel.com
• resource-10-best-indian-foods
A larger form for a URL is:
scheme://host/resource?query#fragment
The query is a way of passing parameters in the URL to the endpoint e.g. Google uses query parameters to define the search term and the page:
https://www.google.co.uk/?q=test&start=10#q=test
______________________________________________________________________________
15. Describe what are HTTP verbs?
A web browser will usually make GET requests and POST requests.
GET requests to ask to read information from the server e.g. clicking on a link.
POST requests supply information to the server e.g. submitting a form.
GET requests do not have a body, and just consist of the Verb, URL, and the Headers.
POST requests can have a payload body.
When working with a Web Application or HTTP API the typical HTTP Verbs used are:
GET, to read information.
POST, to create information.
PUT, to amend or create information.
DELETE, to delete information.
______________________________________________________________________________
Course Alert
If you are interested in learning API testing, check out some of the popular courses on Rest Assured, SoapUI, Python API testing below:
A Quick Note
Please remember all these courses comes with 100% Lifetime access and free updates for Lifetime!!
Please click on the link Top 30 API Testing Interview Questions and Answers – Part 2 to continue to part-2 series of this article.