使用extract_binds
元素保存一个测试的输出。在pyresttest/examples/miniapp-extract-validate.yaml
的pyrestest
存储库中有一个使用示例:
- config:
- testset: "Demonstrate use of extract after creating a person"
- test: # create entity by POST
- name: "Create person"
- url: "/api/person/"
- method: "POST"
- body: '{"first_name": "Test","last_name": "User","login": "testuser"}'
- headers: {Content-Type: application/json}
- expected_status: [201]
- extract_binds:
- 'id': {'jsonpath_mini': 'id'}
- test:
- name: "Get person you just created and validate them"
- url: {'template': "/api/person/$id/"}
- validators:
- compare: {jsonpath_mini: 'id', comparator: 'str_eq', expected: {template: '$id'}}
- extract_test: {jsonpath_mini: 'login', test: 'exists'}
来源
2016-01-20 13:45:29
drs