Example
We have an app that exposes create , read , update , and delete operations for customer records. Records are being served under /customers .Here is an example of a CRUD operations test. Groovy package scenarios.rest.springboot import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario("CRUD operations for customer") { def customerPayload = [firstName: "FN", lastName: "LN"] // new customer data def id = http.post("/customers", customerPayload) { return id // return id value from response body } http.get("/customers/${id}") { body.should == customerPayload // only specified properties will be asserted against } def changedLastName = "NLN" http.put("/customers/${id}", [*:customerPayload, lastName: changedLastName]) { lastName.should == changedLastName // specifying body is optional } http.get("/customers/${id}") { firstName.should == "FN" lastName.should == changedLastName } def changedFirstName = "NFN" http.patch("/customers/${id}", [firstName: changedFirstName]) http.get("/customers/${id}") { firstName.should == changedFirstName lastName.should == changedLastName } http.delete("/customers/${id}") { statusCode.should == 204 } http.get("/customers/${id}") { statusCode.should == 404 } } Java package com.example.tests.junit5; import org.testingisdocumenting.webtau.junit5.WebTau; import org.junit.jupiter.api.Test; import java.util.Map; import static org.testingisdocumenting.webtau.WebTauDsl.*; @WebTau public class CustomerCrudJavaTest { @Test public void crud() { Map<String, ?> customerPayload = aMapOf( // new customer data "firstName", "FN", "lastName", "LN" ); int id = http.post("/customers", customerPayload, ((header, body) -> { return body.get("id"); // return id value from response body })); http.get("/customers/" + id, ((header, body) -> { body.should(equal(customerPayload)); // only specified properties will be asserted against })); String changedLastName = "NLN"; Map<String, ?> changedCustomerPayload = aMapOf( "firstName", "FN", "lastName", changedLastName); http.put("/customers/" + id, changedCustomerPayload, ((header, body) -> { body.get("firstName").should(equal("FN")); body.get("lastName").should(equal(changedLastName)); })); http.get("/customers/" + id, ((header, body) -> { body.should(equal(changedCustomerPayload)); })); http.delete("/customers/" + id, ((header, body) -> { header.statusCode().should(equal(204)); })); http.get("/customers/" + id, ((header, body) -> { header.statusCode().should(equal(404)); })); } }