recent posts

RESTinstance - How to do Schema Validation

Tip of the day

When you are testing schemas using the RESTinstance library, you need to ensure that the `Expect Response` call is always made before your actual REST verb call. Generally, you will want to make your `Expect Response` call in the Test Setup since most of your test cases will likely have the same schema response.

If you tried using the `Expect Response` call after a REST verb, the keyword will always pass since there is no response for it to actually verify. This is because the `Expect Response` call is only checked during the REST verb call, so if you call it after a response has been made, then nothing will occur!! Don't fall into the trap of keywords passing without first verifying it with a known good and bad state! Hope this helps!

Example Test Case Usage

POST Sign Up    Expect Response     ${CURDIR}/schemas/valid/signup_schema.json
    POST        /signup             body={"user": "Bob", "pw": "badpw"}


Example Schema

{
   "status":{
      "type":"integer",
      "enum":[
         200,
         201,
         204
      ]
   },
   "body":{
      "type":"object",
      "properties":{
         "token":{
            "type":"string"
         },
         "email":{
            "type":"string"
         },
         "id":{
            "type":"string"
         }
      },
      "required":[
         "id",
         "token"
      ]
   }
}

RESTinstance - How to do Schema Validation RESTinstance - How to do Schema Validation Reviewed by JJ The Engineer on 3:49 PM Rating: 5

No comments:

Powered by Blogger.