As of now tavern has pytest_tavern_beta_after_every_test_run for performing some task after every test run.
But there can be a option cleanup or some better name for it, in order to perform task when test fails.
Something like this
test_name: Get some fake data from the JSON placeholder API
stages:
- name: Add permission to read user
request:
url: https://example.com/add-permission
method: GET
response:
status_code: 200
save:
json:
perm_id: id
- name: Make sure we have the right ID
request:
url: https://example.com/getid/1
method: GET
response:
status_code: 200
- name: Remove permission to read user
request:
url: https://example.com/remove-permission/{perm_id}
method: GET
response:
status_code: 200
cleanup:
-name : Remove permission
request: https://example.com/remove-permission/{perm_id}
method: GET
The above example illustrates why we need cleanup options, so cleanup executes only if test fails in between.
As of now tavern has
pytest_tavern_beta_after_every_test_run
for performing some task after every test run.But there can be a option
cleanup
or some better name for it, in order to perform task when test fails. Something like thisThe above example illustrates why we need cleanup options, so cleanup executes only if test fails in between.