Scenario: Create a vehicle xxxx
Given I set bearer token accesstoken
And I set body parameters id and 123456
And I set body parameters name and R_123456
When I POST to xxxxx-routes-shops/v1/shops
Then I store the value of body path $.id as shopid in global scope
Scenario: retrieving a vehicle schduling shop based on shop id
Given I set bearer token accesstoken
When I GET xxxxx-routes-shops/v1/shops/shopid // here I want to bind the above stored dynamic value shopid in the url, it is not working,
Then response code should be 200
# update a shop (for example, VehicleSchedule-routes-shops/v1/shops?page=0&Size=13)
Scenario: Update a vehicle schduling shop
Given I set bearer token accesstoken
When I POST to xxxx-routes-shops/v1/shops/shopid // here also (ex shopid=12345)
Then I store the value of body path $.id as shopid in global scope
Just I want to bind the dynamic value to the url ex: xxxx-routes-shops/v1/shops/{12345}
Please advise.
Solved! Go to Solution.
Hi @kumar
For this you will need to write some extensions (gherkin). Add the following code snippets to your init.js or any other appropriate js files within the step_definitions directory
this.When(/^I get the shop info created$/, function (callback) { var shopId = this.apickli.getGlobalVariable("shopid"); this.apickli.get("xxxx-routes-shops/v1/shops/"+shopId, function (error, response) { if (error) { callback(new Error(error)); } callback(); }); }); this.When(/^I update shop info$/, function (callback) { var shopId = this.apickli.getGlobalVariable("shopid"); this.apickli.post("xxxx-routes-shops/v1/shops/"+shopId, function (error, response) { if (error) { callback(new Error(error)); } callback(); }); });
Update your feature to
Scenario: Create a vehicle xxxx Given I set bearer token accesstoken And I set body parameters id and 123456 And I set body parameters name and R_123456 When I POST to xxxxx-routes-shops/v1/shops Then I store the value of body path $.id as shopid in global scope Scenario: retrieving a vehicle schduling shop based on shop id Given I set bearer token accesstoken When I get the shop info created Then response code should be 200 Scenario: Update a vehicle schduling shop Given I set bearer token accesstoken When I update shop info Then I store the value of body path $.id as shopid in global scope
Let me know if this works !
Hi @kumar
For this you will need to write some extensions (gherkin). Add the following code snippets to your init.js or any other appropriate js files within the step_definitions directory
this.When(/^I get the shop info created$/, function (callback) { var shopId = this.apickli.getGlobalVariable("shopid"); this.apickli.get("xxxx-routes-shops/v1/shops/"+shopId, function (error, response) { if (error) { callback(new Error(error)); } callback(); }); }); this.When(/^I update shop info$/, function (callback) { var shopId = this.apickli.getGlobalVariable("shopid"); this.apickli.post("xxxx-routes-shops/v1/shops/"+shopId, function (error, response) { if (error) { callback(new Error(error)); } callback(); }); });
Update your feature to
Scenario: Create a vehicle xxxx Given I set bearer token accesstoken And I set body parameters id and 123456 And I set body parameters name and R_123456 When I POST to xxxxx-routes-shops/v1/shops Then I store the value of body path $.id as shopid in global scope Scenario: retrieving a vehicle schduling shop based on shop id Given I set bearer token accesstoken When I get the shop info created Then response code should be 200 Scenario: Update a vehicle schduling shop Given I set bearer token accesstoken When I update shop info Then I store the value of body path $.id as shopid in global scope
Let me know if this works !
Thanks sai saran for providing valuable info.
Could you please provide sample guidance how can I achieve openID connect testcases thru BDD?
Thanks,
Kumar.
User | Count |
---|---|
5 | |
2 | |
1 | |
1 | |
1 |