API Testing Flashcards
What is an API?
An API, or Application Programming Interface, enables communication and data exchange between two separate software systems.
How does API Testing work?
API Testing is testing the Application Programming Interface of any application. It is used to determine whether APIs return the correct response. It is consider a part of Integration Testing, and commonly includes testing REST APIs or SOAP web services with JSON or XML message payloads.
Why API Testing?
Earlier Testing - Once the logic is implemented, tests can be built to validate the correctness in responses and data. No need to wait for the front-end to be built.
Easier Test Maintenance - UIs constantly change and are accessed from different browsers, devices, and screen orientation. This makes using the UI to test relatively unstable, whereas API has no such challenges.
Faster Time To Resolution - When API tests fail, we know exactly where our system broke and where the defect can be found. This allows us to quickly fix the bug.
Speed and Coverage of Testing - 300 UI tests may take 30 hours, whereas 300 API tests could be run in 3 minutes. In short, you’ll find more bugs in less time.
What two things to APIs need?
APIs need a medium (ex: HTTP) and a format (JSON, XML). All web services are APIs, but not all APIs are web services.
What is REST?
REST is an acronym for Representational State Transfer —REST is a way for two computer systems to communicate over HTTP in a similar way to web browsers and servers. REST is an architectural style which permits various data formats such as Plain Text, HTML, XML, and most commonly JSON.
What are the REST API Methods? (HTTP)
POST - Create a REST API resource.
GET - Retrieve information about the REST API resource.
PUT - Update (Replace) a REST API resource.
PATCH - Update (Modify) a REST API resource.
DELETE - Delete a REST API resource or related component.
What are 2 recommendations and constraints for RESTful web services?
Client-Server: SystemA makes an HTTP request to a URL hosted by SystemB, which returns a response, similar to how a browser works. The application makes a request for a specific URL, and the request is then routed to a web server that returns an HTML page.
Stateless: REST is stateless, the client request should contain all the information necessary to respond to a request. In other words, it should be possible to make two or more HTTP requests in any order and the same responses will be received.
What are the HTTP response status codes?
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Informational responses (100–199) Successful responses (200–299) Redirection messages (300–399) Client error responses (400–499) Server error responses (500–599)
What does API documentation consist of?
An API Documentation will consists of all the developed endpoints information. It should have request method, request body, request headers, request parameters, expected response status code and response body.
What’s the purpose of creating mock REST APIs?
Sometimes we face a situations when there are no API endpoints is available to perform testing. In those situations we can easily develop fake REST API endpoints to perform our testing. And once the actual endpoints is being developed then we can replace the fake REST API with the real one.
What is the JSON Server?
JSON Server the JavaScript json-server library, which can be used to create fake REST API.