Test definition syntax
Information about how the test is defined as a YAML file.
The test is defined as a YAML file with the following sections:
configs
- Displays the configuration values for the variables that are specified in the file.steps
- Displays the flow for the test case and runs through the list of steps in order. Each step has a common set of parameters.
The
type
attribute in the test definition YAML file describes the type of
steps
.requirements: {}
info:
title: "New Configuration YAML File"
version: 2
configs:
globalVariables:
protocol: https://
domain: sample-api.us-east-a.apiconnect.automation.ibm.com
basePath: /bank
inputs:
- default:
value: string
type: array
- second:
value: number
type: string
steps:
- type: request
method: get
url: "{{ configs.globalVariables.protocol }}{{ domain }}{{ globalVariables.basePath }}/branches"
var: branches
mode: json
- type: assert-is
expression: branches
value: "{{ type }}"
- type: assert-exists
expression: branches.[1]
stoponfail: true
- type: assert-is
expression: branches.[0].type
value: string
stoponfail: true
- type: assert-is
expression: branches.[0].address.city
value: string
stoponfail: true
- type: assert-compares
expression1: branches.[0].type
expression2: branches.[7].type
- type: request
method: get
url: https://sample-api.us-east-a.apiconnect.automation.ibm.com/orders/order/AB1234
var: payload
mode: json
- type: assert-equals
expression: payload_response_statusCode
value: 200
ifexists: false
stoponfail: false
- type: assert-equals
expression: payload_response_header_Content-Type
value: application/json
- type: assert-in
expression: payload_response_header_Content-Type
values:
- application/json
- application/swagger+yaml
- type: assert-contains
expression: payload_response_header_Content-Type
value: app
- type: assert-matches
expression: payload_response_header_Content-Type
value: ^[a-z]+/json
- type: assert-exists
expression: "payload"
stoponfail: false
- type: assert-is
expression: "payload.tracking_reference"
value: "string"
ifexists: "false"
stoponfail: false
- type: assert-exists
expression: payload.shipped_at
stoponfail: false
- type: assert-exists
expression: payload.status
stoponfail: false
- type: assert-exists
expression: payload.created_at
stoponfail: false
The following table summarizes the set of parameters that are supported by the
type
attribute.
Parameters | Description | Subattributes |
---|---|---|
globalVariables |
Global variables are settings that remain consistent across the entire test and typically do not change between runs. | You can define any attributes here based on your requirements. For example:
|
inputs | Defines various sets of input parameters that are used across multiple test scenarios. | You can create multiple datasets with any attributes for specific test scenarios. For
example, default and second are two datasets, each with its own
attributes tailored for different scenarios. Note: At least one dataset must be present to run the
test.
|
request |
Make an HTTP request. |
For example,
|
assert-is |
Assert that the type of variable from the response is value . |
For example,
|
assert-exists |
Assert that a particular variable specified in expression exists. |
For example,
|
assert-equals |
Assert that a variable is equal to value . |
For example,
|
assert-greater |
Assert that the variable is greater than value . |
For example,
|
assert-less |
Assert that the variable is lesser than value . |
For example,
|
assert-in |
Assert that the element that is identified by a given expression matches at least one item from a given list. |
For example,
|
assert-matches |
Assert that the value of the element that is identified by a given expression matches a specified format. |
For example,
|
assert-compares |
Assert that the two elements are equivalent in some way. |
For example,
|
assert-contains |
Assert that the value of the element that is identified by a given expression contains a specific substring. |
For example,
|
each |
Loop over the array that is referenced in the expression carrying out the substeps for each item found. |
For example,
|
For more information about assigning variables on a YAML configuration file, see Variable assignment in YAML configuration.