Wednesday, June 08, 2011

REST-assured Tricks How to test Array of values -JSON

RESTful web services often return multiple values. Some times in form of an array.
To test for multiple values we can use .hasItems()
hasItems() works only for JSON
// test multiple values
String result=  given().header("accept", "application/json")
  .expect().body("quote.symbol", hasItems("SYMBOLICIC9","SYMBOLICIC1","SYMBOLICIC9"))
  .when()
  .get("/RestFullDayTrader/resources/quotes").asString();

1 comment:

Julio said...

How do you submit a POST/PUT JSON array?
I have been looking for ways of adding them as a parameter or body, but it is not working