taverntesting / tavern

A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax
https://taverntesting.github.io/
MIT License
1.02k stars 193 forks source link

Variable in skip when on test #881

Closed lvijnck closed 12 months ago

lvijnck commented 1 year ago

I was trying to do something along the lines of the following code snippet, i.e., conditionally disable a step of my test. This seems to not interpolate the vars.

test_name: Dummy

stages:
  - name: Model call without authentication header
    skip: !bool "{tavern.env_vars.SKIP}
    request:
       ...
michaelboulton commented 12 months ago

Currently isn't very clear from the docs but just having skip in a stage will cause it to be skipped no matter what the value is. Adding interpolation would be something extra that would need to be added.

michaelboulton commented 12 months ago

This is fixed with the caveat that any files that are included need to be in .yaml format (not json) and any possible format variables have the !raw tag before them, eg https://github.com/taverntesting/tavern/blob/9bdb1060017dae8a61048cbebf63c3fa6baf53e4/tests/integration/881_2.yaml . This is because it is an intended feature of Tavern that included files are normally formatted