Parameterization - gorskip/testing-framework GitHub Wiki

Story configuration supports cascade parametrization. Each configuration sub-element takes value from local paramater, if it doesn't exist parent parameter value is taken. Places where :paramName will be replaced with value of param with name: paramName

Example:

Raw story definition

{
  "name": "Name of suite",
  "params": {
    "apiUrl": "http://localhost:8085/application",
    "bodyExpectedType": "CONTAIN"
  },
  "tests": [
    {
      "params": {
        "employeeName": "Janusz",
        "departmentName": "DEPARTMENT_NAME"
      },
      "name": "Create new employee",
      "tag": "post",
      "rest": {
        "params": {
          "departmentName": "IT"
        },
        "request" : {
          "method": "POST",
          "url": ":apiUrl/employee",
          "body":
          {
            "name": ":employeeName",
            "department": ":departmentName"
          },
          "headers": {}
        },
        "expected": {
          "status": 200,
          "body": {
            "name":":employeeName",
            "department": ":departmentName"
          },
          "headers": {},
          "type": {
            "status": 201,
            "body": ":bodyExpectedType",
            "withOrder" : false
          }
        }
      },
      "db": {
        "query": "SELECT NAME, :departmentName FROM EMPLOYEE"
      }
    }
  ]
}
Suite parameter:
"url": ":apiUrl/employee"

:apiUrl will be replaced with value from TestSuite parameter apiUrl

Test parameter
"body": {
  "name": ":employeeName",
  "department": ":departmentName"
}

name parameter value will be replaced with value from Test parameter employeeName

Rest parameter
"body": {
  "name": ":employeeName",
  "department": ":departmentName"
}

department parameter value will be replaced with value from Rest parameter departmentName

"type": {
  "status": 201,
  "body": ":bodyExpectedType",
  "withOrder": false
}

body parameter value will be replaced with value from Test parameter bodyExpectedType

Parametrized configuration result:

{
  "name": "Name of suite",
  "params": {
    "apiUrl": "http://localhost:8085/application",
    "bodyExpectedType": "CONTAIN"
  },
  "tests": [
    {
      "params": {
        "employeeName": "Janusz",
        "departmentName": "DEPARTMENT_NAME"
      },
      "name": "Create new employee",
      "tag": "post",
      "rest": {
        "params": {
          "departmentName": "IT"
        },
        "request": {
          "method": "POST",
          "url": "http://localhost:8085/application/employee",
          "body": {
            "name": "Janusz",
            "department": "IT"
          },
          "headers": {}
        },
        "expected": {
          "status": 200,
          "body": {
            "name": "Janusz",
            "department": "IT"
          },
          "headers": {},
          "type": {
            "status": 201,
            "body": "CONTAIN"
          }
        }
      },
      "db": {
        "query": "SELECT NAME, DEPARTMENT_NAME FROM EMPLOYEE"
      }
    }
  ]
}