Contain

Use contain matcher to test scenarios like search or list of recently created entries. This way you don't have to assume an existing state of your backend under test.Given the response, we want to make sure there is an entry with a specified firstName and lastName . package scenarios.rest.springboot import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario("list Customers and assert that it contains a specified entry") { http.get("/customers") { body.should contain([firstName: 'FN1', lastName: 'LN1']) } }

List Of Objects

If you want to make sure that all the values in the list are what you need - use TableData . package scenarios.rest.springboot import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario("list Customers and assert with a Table Data") { http.post("/customers", [firstName: "FN1", lastName: "LN1"]) http.post("/customers", [firstName: "FN2", lastName: "LN2"]) http.post("/customers", [firstName: "FN3", lastName: "LN3"]) http.get("/customers?sortBy=firstName") { body.should == ['firstName' | 'lastName'] { __________________________ 'FN1' | 'LN1' 'FN2' | 'LN2' 'FN3' | 'LN3' } } http.doc.capture('list-match') }

Order Agnostic Match

Use *key column(s) if list order is not guaranteed package scenarios.rest.springboot import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario("list Customers and assert with a Table Data using key column") { def id1 = createCustomer firstName: "FN1", lastName: "LN1" def id2 = createCustomer firstName: "FN2", lastName: "LN2" def id3 = createCustomer firstName: "FN3", lastName: "LN3" http.get("/customers") { body.should == ['*id' | 'firstName' | 'lastName'] { _________________________________ id2 | 'FN2' | 'LN2' id1 | 'FN1' | 'LN1' id3 | 'FN3' | 'LN3'} } } def createCustomer(Map payload) { return http.post("/customers", payload) { id } }