Sobes.tech
Junior — Middle

Have you had experience automating API testing using REST Assured?

sobes.tech AI

Answer from AI

Yes, I have experience automating API testing using REST Assured. This tool allows writing tests for RESTful services in Java with a convenient and readable syntax.

Example of a simple test with REST Assured:

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class ApiTest {
    @Test
    public void testGetUser() {
        given()
            .baseUri("https://jsonplaceholder.typicode.com")
        .when()
            .get("/users/1")
        .then()
            .statusCode(200)
            .body("username", equalTo("Bret"));
    }
}

REST Assured allows checking the response status, body content, headers, and much more, which is convenient for automating API testing.