Created
February 2, 2023 11:00
-
-
Save burcuakkayaa/1454ce0aadc9565d4df7ef304a83f0b8 to your computer and use it in GitHub Desktop.
This file contains 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
Feature: Create A new Pet | |
Background: The Request Body Configuration | |
# Set a configuration for the payload | |
* url baseUrl | |
* def requestPayload = read('classpath:payload/pet.json') #read the json file | |
* set requestPayload.id = Java.type('utils.TestDataCreator').getID() #get value from java class | |
* set requestPayload.category.id = Java.type('utils.TestDataCreator').getID() #get value from java class | |
* set requestPayload.category.name = Java.type('utils.TestDataCreator').getDogCategoryName() #get value from java class | |
* set requestPayload.name = Java.type('utils.TestDataCreator').getDogName() #get value from java class | |
* set requestPayload.photoUrls[0] = Java.type('utils.TestDataCreator').getFileName() #get value from java class | |
* set requestPayload.tags[0].name = requestPayload.name #get value from java class | |
* set requestPayload.status = Java.type('utils.TestDataCreator').getStatus()[0] #get value from java class | |
Scenario: Add a new pet to the store | |
Given header Content-Type = 'application/json' | |
And path '/v2/pet' | |
And request requestPayload | |
When method post | |
Then status 200 | |
And match response.id == '#present' | |
And match $.name == requestPayload.name | |
And match $.category.name == requestPayload.category.name | |
And match $.status == requestPayload.status | |
# Find the pet by ID | |
Given header Content-Type = 'application/json' | |
And path '/v2/pet/' + response.id | |
When method get | |
Then status 200 | |
And match $.id == requestPayload.id | |
And match $.category.id == requestPayload.category.id | |
And match $.category.name == requestPayload.category.name | |
And match $.name == requestPayload.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment