General questions Flashcards
What does API stand for?
application programming Interface
What kind of requests did you send?
I have worked on all kinds of CRUD operation requests
Post, GET, Put, Patch, Delete, Head
What OPTIONS http method is for?
Specifies what kind of actions are available for certain request URLs
( If API provides such options ).
What HEAD http method and why did you use it?
The HEAD method asks for a response identical to that of a GET request, but without the response body. Could HEAD request could be used to read its Content-Length header to check the file size without actually downloading the file.
How did you do API testing? What was your purpose in your last project?
- I did API testing for an internal project employee info. An OLD Application exposed the restful api for easy integration with other apps. So I test that the app functionality works in API layer. i have experience in testing and automating in postman and using Rest Assured library.
The difference between PUT and PATCH?
PUT is used for complete update.
PATCH is used for partial update.
The difference between PUT and POST
PUT is used for complete update of existing data.
PATCH is used for adding new data to the server.
Give a step by step example of how you would automate a testcase API side.
First, I would read the documentation( functional requirements ) of the application. Understand each endpoint including - authorization - authentication and understand relevant information such as: - query parameters - headers - expected status codes - response body - response headers
I would test it out manually in postman to get results for both positive and negative responses.
Then, I write test scenarios and assertions around those expected outcomes according to the documentation
Finally, I can write in both postman, and Rest Assured latest project i worked on was a Rest Assured Maven project.
If you need API authentication, how do you attach it to your request? Types of authentication you know in API?
A few Experiences:
Basic authentication
Token based authentication
- bearer token in authentication header
API key in custom header
API key in query param
oAuth2
Give an example of an API test you recently wrote and how detailed you went with the test?
most recently I had a POST /employees endpoint that expected a json as a payload and it has a restriction on the field values such as name length, phone number, email verifications along with positive scenarios where i add correct json payload and expected 201 status code with valid headers and response payload. I added negative scenarios for all kinds of 400 Bad Request scenarios.
- either name as invalid length
- phone or email in valid format
- multiple invalid inputs
Additionally i added a GET /employee/{id} requests to verify the data was added correctly. Same flow with PUT and PATCH requests
How do you validate Json body?
I can do verification of json body both in postman and Rest Assured. In postman, save the json response as a JavaScript object and access the property of the object for verification.
In Rest Assured, I use Json Path to capture the value of the field to be verified and compare that with expected result in the test.
How detailed are you when you test with postman?
I organize my collection according to the functionality of the app.
The collection is designed to go through multiple scenarios by carrying data created in previous steps to make it stable.
For example while testing DELETE requests, instead of relying on data that exists in the app, I create my own data with POST and use as test data.
Tested all negative scenarios like 403 forbidden response to make sure only those who have authority can make authorized requests.
How would you validate only part of the body of a response?
Capture the value from the json and compare that according to the expected result. In some scenario, I also add additional validation for Json Schema to make sure the Json Structure is a expected according to the requirements.
How do you test the structure of your Json response without having to verify the actual value of the field?
I do Json Schema validation to verify the structure of the Json response. I have Json Schema file that I got from developers to describe how the response structure should look like in Rest Assured project, I have Json-schema-validator dependency. I make a GET request to /products and assert that
.body(matchesJsonSchemaInClassPath(“product-schema.json”))
Do you only do Status Code validations? What other part of the API do you validate?
Status Codes Headers Body XML or Json Structure of the body with schema Optionally response time.