[Week 12] - API Summer Winners & Script Tasks
Hi all,
It’s Monday already, so I’m happy to announce our Week 12 API Summer 2018 winners:
1st place - $50 gift card |
with 22 points (TechCorner topic included) |
|
2nd place - $35 gift card |
with 15 points |
|
3rd place - $15 gift card |
with 6 points |
Congratulations, everyone!
We have only one week of API Summer left, so check out our additional tasks today and put forth your greatest effort to win! Create scripts based on these tasks and get 2 points to your score:
- Dispatching based on the values in Request Body (ServiceV)
Create a REST virtual service from the Petstore Swagger specification and add a dispatching script for the "POST /v2/pet" resource.
A sample request:
JSON |
XML |
{ |
<Pet> |
The dispatching condition:
- If the "name" property contains more than 3 characters, and the "status" value is one of
Unknown macro: {available, pending or sold} |
return the "OK" response (HTTP status code is 200, body is "{"result": "OK"}" or "<result>OK</result>" depending on the media type of the request).
- Otherwise, return the "Bad Request" response (HTTP status code is 400, body is "{"error": "Invalid Request"}" or "<error>Invalid Request</error>" depending on the media type of the request.
- Enabling/disabling TestCases depending on tags values
Currently, you can pass the -T argument to force TestRunner to run only TestSuites or TestCases with specific tags. At that, if you pass several tags, the items containing all these tags (e.g. tag1 AND tag2 AND tagN) will be run.
Your task is to run TestCases and TestSuites which contain tag1 OR tag2 OR tagN.
For this, create a Project Setup script -
- which checks the values of the TestCaseTags and TestSuiteTags Global Properties (they are passed as command-line arguments and their format is "tag1,tag2,tagN");
- and which disables the corresponding items, which don't contain any of the listed tags.
- Adding and assigning a new tag
Create a script, which adds a new tag and assigns it to all TestCases within a TestSuite.