{"id":9456,"library":"allure-pytest-bdd","title":"Allure pytest-bdd integration","description":"allure-pytest-bdd provides integration between the Allure reporting framework and pytest-bdd, allowing users to generate rich, interactive test reports for BDD scenarios written with Gherkin. It is part of the broader Allure Python ecosystem, currently at version 2.15.3, and receives frequent, usually minor, updates.","status":"active","version":"2.15.3","language":"en","source_language":"en","source_url":"https://github.com/allure-framework/allure-python","tags":["pytest","bdd","testing","reporting","allure","gherkin"],"install":[{"cmd":"pip install allure-pytest-bdd","lang":"bash","label":"Install package"},{"cmd":"npm install -g allure-commandline --save-dev","lang":"bash","label":"Install Allure Commandline (required for viewing reports)"}],"dependencies":[{"reason":"Core Allure integration with pytest.","package":"allure-pytest"},{"reason":"Required for defining BDD scenarios.","package":"pytest-bdd"},{"reason":"Test framework orchestrator.","package":"pytest"}],"imports":[{"note":"The 'allure' object for decorators, attachments, and steps is typically imported directly. The underlying implementation comes from 'allure-python-commons' but is exposed via the 'allure-pytest' plugin.","symbol":"allure","correct":"import allure"},{"note":"BDD scenarios are defined using 'pytest_bdd' components.","symbol":"scenario","correct":"from pytest_bdd import scenario"}],"quickstart":{"code":"# features/example.feature\n# Feature: Basic BDD scenario\n#\n#   Scenario: User logs in successfully\n#     Given a user is on the login page\n#     When the user enters valid credentials\n#     Then the user should be redirected to the dashboard\n\n# test_example.py\nimport pytest\nimport allure\nfrom pytest_bdd import scenario, given, when, then\n\n@scenario('features/example.feature', 'User logs in successfully')\ndef test_login():\n    \"\"\"This is the test for the login scenario.\"\"\"\n    pass\n\n@given('a user is on the login page')\ndef login_page():\n    allure.step(\"Navigated to login page\")\n    assert True\n\n@when('the user enters valid credentials')\ndef enter_credentials():\n    with allure.step(\"Entering username and password\"):\n        allure.attach(\"username: test_user\", name=\"credentials\", attachment_type=allure.attachment_type.TEXT)\n    assert True\n\n@then('the user should be redirected to the dashboard')\ndef dashboard_redirect():\n    allure.dynamic.tag(\"login-flow\")\n    assert True\n\n# To run tests and generate Allure report:\n# pytest --alluredir=allure-results\n\n# To open the report in your browser (requires Allure commandline):\n# allure serve allure-results","lang":"python","description":"This example demonstrates a basic `pytest-bdd` scenario integrated with `allure-pytest-bdd`. It includes a feature file and a test file with step definitions. The `allure.step` and `allure.attach` calls show how to enhance the report. Running `pytest` with `--alluredir` generates the report data, which can then be served locally using the Allure commandline tool."},"warnings":[{"fix":"Install `allure-commandline` (e.g., `npm install -g allure-commandline`) and run `allure serve allure-results` after `pytest --alluredir=allure-results`.","message":"Viewing Allure reports requires the separate Allure commandline tool to be installed and run after tests. Generating test results with `--alluredir` only produces raw data files.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `allure-pytest-bdd>=2.14.0` to fully leverage the Allure API and ensure all features are supported, including expected failures (xfail), dynamic titles, gherkin tags conversion, and descriptions from feature/scenario metadata.","message":"Prior to version 2.14.0, the `allure-pytest-bdd` integration had limited support for the full Allure API (e.g., dynamic titles, attachments within steps, xfail).","severity":"breaking","affected_versions":"<2.14.0"},{"fix":"Upgrade to `allure-pytest-bdd>=2.14.3` to ensure that only user-defined markers and Gherkin tags are converted to Allure tags, avoiding conflicts with reserved pytest markers.","message":"In `allure-pytest-bdd` versions before 2.14.3, built-in pytest markers might have been incorrectly converted to Allure tags, leading to unintended tags in reports.","severity":"gotcha","affected_versions":"<2.14.3"},{"fix":"Update `allure-pytest-bdd` to version `2.14.3` or newer to resolve issues with fixture titling in newer `pytest` versions.","message":"When using pytest version 8.4 or later with `allure-pytest-bdd` prior to 2.14.3, attempting to change a fixture's title could result in errors.","severity":"gotcha","affected_versions":"<2.14.3 with pytest>=8.4"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure `allure-pytest-bdd` (which depends on `allure-pytest`) is installed: `pip install allure-pytest-bdd`.","cause":"The `allure-pytest` plugin is not installed or not properly registered with pytest.","error":"pytest: error: unrecognized arguments: --alluredir=allure-results"},{"fix":"Install `pytest-bdd`: `pip install pytest-bdd` (or `pip install allure-pytest-bdd` which includes it).","cause":"The `pytest-bdd` library is not installed, which is a core dependency for `allure-pytest-bdd`.","error":"ModuleNotFoundError: No module named 'pytest_bdd'"},{"fix":"First, run your tests with `pytest --alluredir=allure-results` to generate the report data. Then, ensure you are running `allure serve` from the same directory where `allure-results` was created, or specify the correct path.","cause":"The `allure serve` command was run, but the specified results directory (`allure-results` by default) either doesn't exist or contains no valid Allure report data.","error":"No results found. Wiping out allure-results folder"},{"fix":"Verify that the scenario name and feature file path provided in `@scenario('features/example.feature', 'Scenario: User logs in successfully')` precisely match the content and location of your `.feature` file.","cause":"The scenario name or feature file path in the `@scenario` decorator does not exactly match the Gherkin feature file.","error":"pytest_bdd.exceptions.NoScenarioFound: No scenario 'Scenario: User logs in successfully' in features/example.feature"}]}