Exam >
On this page

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

attributedescexample
vars List of comma-separated variable names Required. Default: -
vars="var1, var2"
separator value separator to use in e:vals tag Optional. Default: ,
varsSeparator="|"
vals.desc Description of specific parameter values Optional. Default: number
desc="some description"

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

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:
GET mirror/headers
Content-Type application/json
Use cases:
1) Parametrized headers and response body

POST

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:
POST mirror/body
Content-Type application/json
Use cases:
2) Parametrized request body and response body

DELETE

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:
DELETE mirror/headers
Content-Type application/json
Use cases:
3) Parametrized headers and response body

PUT

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:
PUT mirror/body
Content-Type application/json
Use cases:
4) Parametrized request body and response body

SOAP

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:
POST mirror/body
Content-Type application/soap+xml; charset=UTF-8;
Use cases:
5) Parameterized name of file
POST mirror/body HTTP/1.1
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>

More