I am using Tavern
to test my web server in python3
. Tavern
is to test the service based on a predefined yaml
file. I have a backend API when response an auto generated id value to client. How can I test the auto-generated response? And how can I save the response to an variable and use it for other tests?
test_name: Test phonebook service
stages:
- name: Make sure we can create new contact
request:
url: http://localhost:8080/v2/contact
method: POST
json:
username: testUser
first_name: first
last_name: last
email: test@email.com
password: "123456"
phone: "111111"
response:
status_code: 200
body:
contact_id: # This is auto generated id from backend
As the above example, it sends a POST request to the server and expect 200 status code in the response. But I don't know how to check the contact_id
which is an integer generated by the backend.
Also, I'd like to save the contact_id
in a variable as the input for other APIs.