CheckOps home

Tools directory

P

CheckOps

pytest-bdd

pytest-bdd is an MIT-licensed BDD plugin for pytest that runs Gherkin feature files as pytest tests, with steps implemented as fixtures-aware Python functions.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

pytest-bdd implements a subset of the Gherkin language so behaviour-driven scenarios run inside pytest. Its key advantage over standalone BDD runners is that it reuses pytest’s ecosystem: fixtures, parametrisation, markers, plugins such as pytest-xdist and pytest-cov, and pytest’s reporting. Scenarios become ordinary pytest test items.

You bind feature files with scenario(...) or scenarios("features"), and implement steps with @given, @when and @then. Steps can request pytest fixtures directly, and target_fixture lets a step return a value that later steps receive as a fixture. Step arguments are parsed with parsers.parse, parsers.cfparse or regular expressions, and scenario outlines, backgrounds and tags (mapped to pytest markers) are supported. Report options include Cucumber JSON output for living-documentation tools. It is maintained by the pytest-dev organisation, with commits in November 2026; versions are published on PyPI rather than as GitHub releases.

The source code is at pytest-dev/pytest-bdd on GitHub under the MIT licence, with about 1,500 stars; the most recent commit was on 9 November 2026.

Features

  1. Runs in pytest: Scenarios are pytest tests with full plugin support.
  2. Fixture injection: Steps use pytest fixtures and target_fixture.
  3. Flexible parsers: parse, cfparse and regex step arguments.
  4. Cucumber JSON: Output for reporting tools.

Pros

  1. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 9 November 2026.

Cons

  1. Gherkin subset: Not every Gherkin feature is supported; check the docs.
  2. Binding boilerplate: Feature files must be bound to test modules.
# features/login.feature
Feature: Login
  Scenario: Valid credentials
    Given a registered user "ana"
    When she logs in with password "secret"
    Then she sees the dashboard
# tests/test_login.py
from pytest_bdd import scenarios, given, when, then, parsers

scenarios("../features/login.feature")

@given(parsers.parse('a registered user "{name}"'), target_fixture="user")
def user(name, db):
    return db.create_user(name, password="secret")

@when(parsers.parse('she logs in with password "{pw}"'), target_fixture="page")
def login(client, user, pw):
    return client.login(user.name, pw)

@then("she sees the dashboard")
def dashboard(page):
    assert "Dashboard" in page.text

Resources:

Pricing

pytest-bdd is free and open source under the MIT licence.

  1. pytest users adopting BDD without leaving pytest.
  2. Teams that want Gherkin plus pytest fixtures and plugins.

Conclusion

pytest-bdd is the natural BDD choice for pytest teams, combining readable scenarios with pytest’s fixtures and ecosystem.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with pytest-bdd side by side.