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.
- Unit Testing
- Python
- Open source
- Free
- Bdd
- Integration Testing
- Unit testing
- Integration testing
- End-to-end & functional
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
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
- Runs in pytest: Scenarios are pytest tests with full plugin support.
- Fixture injection: Steps use pytest fixtures and
target_fixture. - Flexible parsers: parse, cfparse and regex step arguments.
- Cucumber JSON: Output for reporting tools.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 9 November 2026.
Cons
- Gherkin subset: Not every Gherkin feature is supported; check the docs.
- Binding boilerplate: Feature files must be bound to test modules.
Usage and Links (Example)
# 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.
Recommended for?
- pytest users adopting BDD without leaving pytest.
- 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.
Bbehavebehave is a BSD-licensed behaviour-driven development framework for Python that runs Gherkin feature files with step definitions written in Python.Compare with pytest-bdd- Ppytestpytest is the usual Python test runner: plain asserts, fixtures, parametrization, and a large plugin set.Compare with pytest-bdd
CCucumberCucumber is the open-source BDD tool that runs Gherkin feature files against step definitions. It is not CucumberStudio.Compare with pytest-bdd
RRobot FrameworkGeneric automation framework for acceptance testing and RPA.Compare with pytest-bdd
RReqnrollReqnroll is a BSD-3-Clause .NET port of Cucumber based on the SpecFlow code base, running Gherkin scenarios with MSTest, NUnit, xUnit or TUnit on .NET Framework 4.6.2+ through .NET 10.Compare with pytest-bdd
SSerenity BDDSerenity BDD is an Apache-2.0 Java library for writing automated acceptance tests with rich living-documentation reports, integrating with JUnit, Cucumber and Selenium and supporting the Screenplay pattern.Compare with pytest-bdd