Created
May 13, 2023 03:46
-
-
Save PramodDutta/a8206bd9655565f282e2b43dbfbfb73a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pm.test("Status code is 200", function () { | |
| // Postman has created their DSL - Domain Specific Language | |
| // To write the Testcases | |
| // Remeber? | |
| pm.response.to.have.status(200); | |
| }); | |
| pm.test("Response time is less than 1200ms", function () { | |
| pm.expect(pm.response.responseTime).to.be.below(1200); | |
| }); | |
| pm.test("set your booking Id",function(){ | |
| var responseData = pm.response.json(); | |
| pm.environment.set("e_bookingId_int2",responseData.bookingid); | |
| }) | |
| pm.test("TC1 - Verify that firstname expected",function(){ | |
| var responseData = pm.response.json(); | |
| var fname = responseData.booking.firstname; | |
| pm.expect(fname).to.equal("Pramod"); | |
| }) | |
| pm.test("TC2 - Verify checkin is as expected",function(){ | |
| var responseData = pm.response.json(); | |
| var check_in = responseData.booking.bookingdates.checkin; | |
| pm.expect(check_in).to.equal("2023-05-01"); | |
| //firstName should be a String | |
| pm.expect(responseData).to.have.property('bookingid'); | |
| }) | |
| pm.test("TC3 - Verify booking null is not expected",function(){ | |
| var responseData = pm.response.json(); | |
| var bookingid = responseData.bookingid; | |
| pm.expect(bookingid).not.to.equal(null); | |
| //firstName should be a String | |
| pm.expect(responseData).to.have.property('bookingid'); | |
| }) | |
| var schema = { | |
| "type": "object", | |
| "required": [ | |
| "bookingid", | |
| "booking" | |
| ], | |
| "additionalProperties": true, | |
| "properties": { | |
| "bookingid": { | |
| "type": "integer" | |
| }, | |
| "booking": { | |
| "type": "object", | |
| "required": [ | |
| "firstname", | |
| "lastname", | |
| "totalprice", | |
| "depositpaid", | |
| "bookingdates", | |
| "additionalneeds" | |
| ], | |
| "additionalProperties": true, | |
| "properties": { | |
| "firstname": { | |
| "type": "string" | |
| }, | |
| "lastname": { | |
| "type": "string" | |
| }, | |
| "totalprice": { | |
| "type": "integer" | |
| }, | |
| "depositpaid": { | |
| "type": "boolean" | |
| }, | |
| "bookingdates": { | |
| "type": "object", | |
| "required": [ | |
| "checkin", | |
| "checkout" | |
| ], | |
| "additionalProperties": true, | |
| "properties": { | |
| "checkin": { | |
| "type": "string" | |
| }, | |
| "checkout": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "additionalneeds": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| pm.test('Schema is valid', function () { | |
| var responseData = pm.response.json(); | |
| pm.expect(tv4.validate(responseData, schema)).to.be.true; | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment