Skip to content
ykangoakridge edited this page Dec 22, 2017 · 2 revisions

Welcome to the pyresttest wiki!

variable templating sample

- config:
    - testset: "demo how to use var in POST body and validator, assume response have json contain the posted value"
    - variable_binds: {
        var_str: 'string123',
        var_int: 123
    }
- test:
    - group: "my group name"
    - name: "variable in validator example"
    - url: "/my/path/"
    - headers: {"Content-Type": "application/json"}
    - method: "POST"
    - body: { template : '{
        "action":"add",
        "mystring":"$var_str",
        "myinteger": $var_int
    }' }
    - expected_status: [200]
- validators:
    - compare: {jsonpath_mini: "my.retured.json.path.str", comparator: "eq", expected: {template : '$var_str'} }
    - compare: {jsonpath_mini: "my.returned.json.path.int", comparator: "eq", expected: {template : '$var_int'} }
Clone this wiki locally