0

How can we verify the Json data type of mentioned fields such as "price", "ck", "name", "enabled" and "tags" in rest assured test.

{
  "odd": {
    "price": 200,
    "ck": 12.2,
    "name": "test this",
    "enabled": true,
    "tags": null
  }
}

Is there any way or any assertion library which provide data type verification as mentioned in rest assured test example where instead of asserting the actual value of given key we can verify only the data type

ValidatableResponse response =
            
given().
    spec(requestSpec).
    headers("authkey", "abcdxxxxxxxxxyz").
    pathParam("uid", oddUid).
when().
    get("/orders" + "/{uid}").
then().
    assertThat().
    statusCode(200).
    body(
           "odd.price",  isNumber(),
           "odd.name", isString(),
           "enabled", isboolean()
           "tags", isNull()
         );
4
  • You seem to have provided the answer already. Are you going through an error? Can you detail it? Jul 23 at 15:21
  • Hello sqa.stackexchange.com/users/12740/jo%c3%a3o-farias I am not sure about the which library to use for this kind of assrtions Jul 23 at 15:44
  • You are already making the assertions. You mean that your second block of code is not working or it is just pseudo-code? Jul 23 at 17:04
  • Yes..it is pseudo-code Jul 24 at 10:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.