Q40 of 40 · REST Assured

How do you structure mentoring for engineers new to REST Assured on a Java team?

REST AssuredLeadrest-assuredleadershipmentoringonboardingteam-development

Short answer

Short answer: Start with the given/when/then mental model and have engineers convert existing cURL commands into REST Assured chains as their first exercise. Pair-program the first test class; introduce RequestSpecBuilder and POJO deserialisation progressively. Avoid teaching filters, parallel execution, and OAuth flows before engineers have shipped 10 passing tests.

Detail

Week 1 — fundamentals: the three-section chain, status code assertions, one JsonPath expression. Exercise: convert 5 existing cURL commands to REST Assured tests against a real test environment.

Week 2 — DRY and structure: RequestSpecBuilder, ResponseSpecBuilder, BaseApiTest. Exercise: refactor week-1 tests to use a shared base class. Code review the result together — this is where they internalise the spec-builder pattern.

Week 3 — data and extraction: .extract(), POJO deserialisation, @ParameterizedTest. Exercise: write a round-trip test (POST → extract ID → GET → assert).

Week 4 — debugging and CI: .log().ifValidationFails(), the common cURL-vs-REST-Assured mismatches, running in CI. Exercise: deliberately break a test, add logging, diagnose the issue.

What to defer: filters, parallel execution, WireMock integration, OAuth 2.0, Allure — introduce after engineers are comfortable with the core pattern. Overloading the curriculum creates dependency on the mentor for every new feature rather than independent fluency.

Code review cadence: review all REST Assured PRs for the first month. Common review comments: static RestAssured.* usage, missing teardown, hard-coded URLs, over-extraction instead of .body() assertions.

// EXAMPLE

// Week 1 exercise: convert this cURL to REST Assured
// curl -X GET https://api.example.com/users/1 //      -H "Authorization: Bearer my-token" //      -H "Accept: application/json"
// Expected: 200 {"id":1,"name":"Alice","email":"alice@example.com"}

// Junior's first REST Assured test
@Test
void getUser_returnsAlice() {
    given()
        .baseUri("https://api.example.com")
        .header("Authorization", "Bearer my-token")
        .accept(ContentType.JSON)
    .when()
        .get("/users/1")
    .then()
        .statusCode(200)
        .body("id",    equalTo(1))
        .body("name",  equalTo("Alice"))
        .body("email", equalTo("alice@example.com"));
}

// Week 2 review feedback: extract baseUri + header to RequestSpecBuilder
// Week 3 exercise: extract the user as a User POJO and assert on it
// Week 4 exercise: add .log().ifValidationFails() to the base spec and break the test

// WHAT INTERVIEWERS LOOK FOR

Progressive curriculum (fundamentals before advanced), hands-on exercises (not just lectures), code review cadence for the first month, and explicit deferral of advanced topics. This reflects experience building team capability rather than just personal REST Assured expertise.

// COMMON PITFALL

Teaching the full framework architecture (service layer, filters, OAuth, parallel) in week 1. Engineers lose confidence when they can't write a test without the full setup. Start with a working test in 3 lines; add layers when fundamentals are solid.