A JavaScript end-to-end testing framework that lets you write browser and mobile tests as readable, user-level steps across multiple engines.
pytest-dev/pytest-bdd
A BDD framework that runs Gherkin feature files as pytest tests, with no separate test runner needed.
- Stars
- 1,473
- Forks
- 256
- Open issues
- 87
- Last commit
- 5 days ago
What is it?
pytest-bdd implements a subset of the Gherkin language, letting teams write requirements as feature files with Given, When, Then steps and bind them to Python test functions. Because it runs on pytest, BDD scenarios sit alongside unit and functional tests and use the same CI setup.
Step implementations are ordinary pytest functions, so existing fixtures can be injected into steps through dependency injection. A given step can also set a named fixture with target_fixture, which lets setup state flow between steps without a shared global context. Step arguments can be parsed with the string, parse, cfparse or re parsers.
The library also supports scenario outlines with multiple example tables, backgrounds, rules, datatables and docstrings, plus tag-to-marker mapping so scenarios can be selected with pytest -m or -k.
Key features
- 01Runs Gherkin feature files as standard pytest tests
- 02Injects pytest fixtures into Given, When and Then steps
- 03Supports scenario outlines with multiple example tables
- 04Offers string, parse, cfparse and regex step argument parsers
- 05Maps Gherkin tags to pytest markers for test selection
Use cases
- Writing acceptance tests from product requirements in plain-language feature files
- Reusing existing pytest fixtures for functional tests of web or API behavior
- Organizing a Python test suite by feature with tag-based test selection
Quick start
- 1
Install pytest-bdd from PyPI
pip install pytest-bdd
Things to know
- Each feature file may contain only one feature.
- Steps must be implemented as Python functions tied to pytest, so it only works in Python test suites.
In collections
Topics
FAQ
- What is pytest-bdd?
- A BDD framework that runs Gherkin feature files as pytest tests, with no separate test runner needed. pytest-bdd implements a subset of the Gherkin language, letting teams write requirements as feature files with Given, When, Then steps and bind them to Python test functions. Because it runs on pytest, BDD scenarios sit alongside unit and functional tests and use the same CI setup.
- Is pytest-bdd free to use? What license does it have?
- pytest-bdd is open source under the MIT license. Check the license terms before using it in commercial products.
- Is pytest-bdd still maintained?
- Actively maintained. The last commit to pytest-bdd was on Nov 2, 2026.
- What can I use pytest-bdd for?
- Writing acceptance tests from product requirements in plain-language feature files Reusing existing pytest fixtures for functional tests of web or API behavior Organizing a Python test suite by feature with tag-based test selection
- How do I install pytest-bdd?
- Install pytest-bdd from PyPI: pip install pytest-bdd
- Where can I get pytest-bdd?
- The source code and installation instructions are on GitHub: https://github.com/pytest-dev/pytest-bdd
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A pytest plugin that runs tests in parallel across multiple CPUs and adds a loop-on-failures mode.
A pytest plugin that lets test functions be coroutines, so you can await asyncio code directly inside tests.
A Python package that finds and runs the example code in docstrings, rewriting the builtin doctest module with an AST-based parser.
Open-source AI testing agent that turns Gherkin feature files into automated end-to-end browser, API, security, accessibility and visual tests.
Open source, keyword-driven automation framework for acceptance testing, ATDD and robotic process automation, written in Python.