Wednesday, June 08, 2011

REST-assured Tricks How to test a value in JSON

Use equalTo()
When the value is a string use single quotes '121'
In the below example the openbalance is a property of useraccount. useraccount is the JSON object name in the JSON.
Some implementation does not return the object name. In such cases replace "useraccount.openbalance" with "openbalance"

String result = given().header("accept", "application/json")
 .expect().body("useraccount.openbalance", equalTo(121),"useraccount.useraccountid",notNullValue())

No comments: