Chaining

Chaining is a way to continue another test that was previously executed

This is the mechanism on how to chain scenarios for Autokin. Let us say that you want to Login the user then use the session token to retrieve user information.

POST https://www.autokinjs.com/login
Headers:
Content-Type: application/json
{
"username": "juan",
"password": "p3dr0"
}
Response:
{
"sessionId": "2AA21boNhOM5zR3Xgn96qw=="
}
GET https://www.autokinjs.com/user/1001
Headers:
Content-Type: application/json
SessionId: 2AA21boNhOM5zR3Xgn96qw==
Response:
{
"id": 1001,
"name": "Juan Pedro",
"age": 30
}

So having that we can have this Feature definition:

@chaining
Feature: My Chaining Feature
As Autokin tester
I want to verify that all API are working as they should
Scenario: Login to the system
Given that a secure endpoint is up at www.autokinjs.com
Given I set Content-Type header to application/json
Given I set the JSON body to
"""
{
"username": "juan",
"password": "p3dr0"
}
"""
When I POST /login
Then response status code should be 200
Then I keep the value of body path "$.sessionId" as "userSessionToken"
Scenario: Get user information
Given that a secure endpoint is up at www.autokinjs.com
Given I set Content-Type header to application/json
Given I set SessionId header from "userSessionToken"
When I GET /user/1001
Then response status code should be 200

As you see in the above example, we login then we store the session token to a variable userSessionToken, the variable name can be anything as long as a one word. Following to our next scenario, as needed by our API, we set the header SessionId to the value of the previously stored data by specifying that we are getting the stored value from the variable userSessionToken.