Step is smallest test assert part and is used in test case.
To define the test yaml type as test step it is mandatory to set
step constant value to
To access test step from test case you need to set step
name: <step name>
Using apimation you can send request with different HTTP methods, multiple query parameters and headers. Description of the main request parameters:
method: available methods are GET, POST, PUT, DELETE, HEAD, OPTIONS. If method is not set, GET method will be pre-set as default method.
url: set your request URL.
headers: you can set any key-value pair as the header. This parameter is optional.
queryParams: you can set any key-value pair as the URL parameters. This parameter is optional.
maxHttpRedirects: you can set max http redirect count. This parameter is optional.
You can use different types of steps. Type of step, mandatory for POST method.
x-www-form-urlencodedtype: used if you want to send simple text/ASCII data. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
form-datatype: no characters are encoded. This value is required when you are using forms that have a file upload control.
rawtype: used if you want to send plain text or JSON or any other kind of string.
binarytype: used to send image, audio, video and text files.
asserttype: used for non-http request steps to test string/int/float assertions.
system-cmdtype: used to be able to use shell scripts or system commands in 'body' property of step definition.
In the test step you can use variables defined in test case or test environment.
$url defined in test environment and query parameter variable
$query defined in test case can be used in the following way:
url: $url queryParams: query: ["$query"]
To find and save data from response to variable you can use
greps. You can use following types: json, xml, text, headers, status, rtt and rsize.
xmlwill enable usage jsonpath and xpath expressions.
texttype is used to extract everything that is in the response body and it possible to use regex groups to extract specific parts of it.
headersis used to get specific header value.
statusused to get response status message.
rttis round trip time i.e. response time in milliseconds.
rsizeis response packet size in bytes.
Apimation offer two types of asserts:
assertQuickby using this assert you can assert response status and response time.
assertby using this assert you can assert json, xml, text, headers, status, rtt, rsize, string, int, float, cmd.
Generate test step using Apimation CLI client by execute following command:
apimation generate step <step name> -f <feature name>
You also can generate test step type with defined type using flag
apimation generate step <step name> -t <type name> -f <feature name>
Available test step types:
Create new YAML test step manually:
<step name>.yamlfile in
stepsfolder with following content:
test: step name: <step name> collection: name: Feature1 method: GET url: $url headers: - Content-Type: application/json greps: - varname: $id type: json expression: $..id asserts: - key: $..title type: json expected: $bookTitle operator: eq
Test step advanced documentation available here