08 Nov 2022.

Tags: Announcements

With the pytest support introduced in Stb-tester v33, you can use pytest-bdd to run Stb-tester from BDD specifications (also known as “Gherkin” syntax, or “Given/When/Then” acceptance criteria).

We don’t endorse or recommend BDD for Stb-tester tests

But if you really want or need to, now you can.

I recommend thinking about ways to reduce boilerplate in the “step definitions” code. In BDD, you have to write code that converts each natural-language “step” in the scenario, to actual Python code that carries out the test. Ideally you could write a small translation layer that automatically converts the scenario steps to Page Object method calls (without having to write “step definitions” manually for every different Page Object class & method).

Here’s a quick example showing one Gherkin “feature” with two “scenarios” — one of them is a “scenario outline” to be run with different parameters or “examples”. They are marked with tags like “@menu” and “@nav”, to enable selecting or deselecting the scenarios to run. The BDD scenarios are on the left, with the Python step definitions on the right. For more details see the pytest-bdd documentation.


You can pass additional command-line options to pytest-bdd in your .stbt.conf file like this:

stbt_version = 33
pytest = --cucumberjson=steps.json

For each test-run, if an artifact called “steps.json” exists, the Stb-tester Portal will show the detailed pass/fail status of each step: