Junior — Middle
Have you used REST Assured for automating REST API testing?
sobes.tech AI
Answer from AI
Yes, I have used REST Assured for automating REST API testing. This tool makes it convenient to write tests in Java, verify server responses, status codes, headers, and response bodies. For example, you can write a test that sends a GET request and checks that the response status is 200 and that the JSON contains the required fields:
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
public class ApiTest {
@Test
public void testGetUser() {
given()
.when().get("https://api.example.com/users/1")
.then()
.statusCode(200)
.body("id", equalTo(1))
.body("name", notNullValue());
}
}