Middle
What libraries did you use for API test automation? How did you validate the responses?
sobes.tech AI
Answer from AI
For automating API testing, I often use libraries such as RestAssured (Java), Requests + Pytest (Python), SuperTest (JavaScript/Node.js), and Postman/Newman for integration tests.
Response validation usually includes:
- Checking the HTTP status (e.g., 200 OK)
- Validating the structure and content of JSON/XML using JSON Schema or XPath
- Checking specific field values
Example with RestAssured:
given()
.when().get("/api/users/1")
.then()
.statusCode(200)
.body("data.id", equalTo(1))
.body("data.email", matchesPattern(".+@.+\\..+"));
Here, we check the status, the presence of the correct id, and the email format.