Wednesday, June 08, 2011

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

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. For XML we have to use hasXPath()
// test multiple values
String result= given().header("accept", "application/xml")
   .expect()
   .body(hasXPath("//symbol[text()='SYM9']"),hasXPath("//symbol[text()='SYM1']"))
   .when()
   .get("/RestFullDayTrader/resources/quotes").asString();

No comments: