Parameterized cases
Parameterized cases are a good way to define and run multiple cases, where the only difference between them is the data.
Overview
To turn e:case
into the parametrized case the e:where
nested tag could be used.
<e:where vars="lang, token" separator=",">
<e:vals desc="english local">en, {{now 'ddMMyyyy'}}</e:vals>
<e:vals desc="russian local">ru, 01012000</e:vals>
</e:where>
Attributes
attribute | desc | example |
---|---|---|
vars |
List of comma-separated variable names | Required. Default: -
|
separator |
value separator to use in e:vals tag |
Optional. Default: ,
|
vals.desc |
Description of specific parameter values | Optional. Default: number
|
Each parameterized case will be zipped from vars
and e:vals
declarations (hence order of vars
and order of values inside e:vals
should match).
Examples
GET
The following markup:
<e:get url="mirror/headers">
<e:case desc="Parametrized headers and response body" headers="Authorization = Bearer {{token}}, Accept-Language = {{lang}}">
<e:expected> { "GET": "/mirror/headers", "Authorization": "Bearer {{token}}", "Accept-Language": "{{lang}}", "cookies": {} } </e:expected>
<e:where vars="lang, token" separator=",">
<e:vals desc="en + now">en, {{now 'ddMMyyyy'}}</e:vals>
<e:vals desc="ru + 01012000">ru, 01012000</e:vals>
</e:where>
</e:case>
</e:get>
will be rendered as:Use cases: | |
---|---|
1) Parametrized headers and response body | |
POST
The following markup:
<e:post url="mirror/body">
<e:case desc="Parametrized request body and response body">
<e:body>{"exact": "{{p1}}", "template": 1}</e:body>
<e:expected>{"exact": "{{p2}}", "template": "{{number}}"}</e:expected>
<e:where vars="p1, p2" separator="|">
<e:vals desc="first">first value of p1 | first value of p1</e:vals>
<e:vals desc="second">second value of p1 | second value of p1</e:vals>
</e:where>
</e:case>
</e:post>
will be rendered as:Use cases: | |
---|---|
2) Parametrized request body and response body | |
DELETE
The following markup:
<e:delete url="mirror/headers">
<e:case desc="Parametrized headers and response body" headers="Authorization = Bearer {{token}}, Accept-Language = {{lang}}">
<e:expected> { "DELETE": "/mirror/headers", "Authorization": "Bearer {{token}}", "Accept-Language": "{{lang}}", "cookies": {} } </e:expected>
<e:where vars="lang, token" separator=",">
<e:vals desc="en + now">en, {{now 'ddMMyyyy'}}</e:vals>
<e:vals desc="ru + 01012000">ru, 01012000</e:vals>
</e:where>
</e:case>
</e:delete>
will be rendered as:Use cases: | |
---|---|
3) Parametrized headers and response body | |
PUT
The following markup:
<e:put url="mirror/body">
<e:case desc="Parametrized request body and response body">
<e:body>{"exact": "{{p1}}", "template": 1}</e:body>
<e:expected>{"exact": "{{p2}}", "template": "{{number}}"}</e:expected>
<e:where vars="p1, p2" separator="|">
<e:vals desc="first">first value of p1 | first value of p1</e:vals>
<e:vals desc="second">second value of p1 | second value of p1</e:vals>
</e:where>
</e:case>
</e:put>
will be rendered as:Use cases: | |
---|---|
4) Parametrized request body and response body | |
SOAP
The following markup:
<e:soap url="mirror/body">
<e:case desc="Parameterized name of file">
<e:body from="/data/soap/{{body}}"/>
<e:expected from="/data/soap/expected.xml"/>
<e:where vars="body">
<e:vals>body.xml</e:vals>
</e:where>
</e:case>
</e:soap>
will be rendered as:Use cases: | |
---|---|
5) Parameterized name of file | |
| 20013ms |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:getItemRequest xmlns:ns2="http://ws.io"> <date>2021-03-12</date> </ns2:getItemRequest> </soap:Body> </soap:Envelope> |