This project shows how to do [BDD] in [Python]
using pytest-bdd, a plugin
for the pytest test automation framework and Allure
framework for generating tests reports.
It exhibits the basics of pytest-bdd
with simple unit- and simple e2e- tests.
Tests are meant to highlight pytest-bdd features,
not to necessarily show testing best practices for scalable solutions.
This project uses Python 3. Use venv to create a virtual environments for dependencies. Use allure to create test reports.
There is 1 feature files that showcase how to use pytest-bdd in various ways:
book_manager.feature- Contains e2e test scenarios for a bookshelf project.
- Tests that book can be added and removed from closet.
- Tests that new book added as unread status to closet.
- Tests for reading books.
To run all tests from the root directory, run pytest.
All the standard
pytest command line options
work.
Use command line options
for filtering and other controls.
Options may also be put inside the pytest.ini
configuration file.
Below are some common options:
# run all tests
pytest
# to understanding that markers can be use
pytest --markers
# filter tests by tags
pytest -m "e2e"
pytest -m "unit"
# print Allure report
# Replace allure-results with the path to the directory specified in the outputFolder setting of the reporter
allure serve allure-results