{"id":5844,"library":"allure-behave","title":"Allure Behave","description":"Allure behave is an adapter for Behave that integrates Behave tests with Allure Report, a flexible and lightweight multi-language test report tool. It enhances standard Behave reporting by providing capabilities for crafting more informative and structured tests, allowing for metadata annotation, test organization, step division, and attachment of files like screenshots. The current version is 2.15.3 and it generally follows the Allure Python project's release cadence, with frequent updates for bug fixes and new features.","status":"active","version":"2.15.3","language":"en","source_language":"en","source_url":"https://github.com/allure-framework/allure-python","tags":["testing","bdd","reporting","behave","allure"],"install":[{"cmd":"pip install allure-behave","lang":"bash","label":"Install package"},{"cmd":"brew install allure  # For macOS\n# Or install via other package managers: https://allurereport.org/docs/gettingstarted-installation/","lang":"bash","label":"Install Allure Report CLI (required)"}],"dependencies":[{"reason":"Required for writing and executing BDD tests.","package":"behave"},{"reason":"Provides core Allure API for Python integrations (installed transitively).","package":"allure-commons"}],"imports":[{"note":"Used as a Behave formatter string in command line or behave.ini","symbol":"AllureFormatter","correct":"behave -f allure_behave.formatter:AllureFormatter ..."},{"note":"Main module for runtime API annotations (e.g., @allure.step, allure.dynamic.issue)","symbol":"allure","correct":"import allure"},{"note":"Required for parallel execution setup in environment.py instead of direct formatter usage on the command line.","wrong":"behave -f allure_behave.formatter:AllureFormatter ... when using behave-parallel","symbol":"allure_report","correct":"from allure_behave.hooks import allure_report"}],"quickstart":{"code":"# 1. features/example.feature\nFeature: Allure Behave Example\n  Scenario: A simple test scenario\n    Given I have a step\n    When I perform an action\n    Then I should see a result\n\n# 2. steps/example_steps.py\nfrom behave import given, when, then\nimport allure\n\n@given('I have a step')\ndef step_have_step(context):\n    pass\n\n@when('I perform an action')\ndef step_perform_action(context):\n    with allure.step('Sub-step: doing something important'):\n        print('Performing action...')\n\n@then('I should see a result')\ndef step_see_result(context):\n    allure.attach('This is some attachment content.', name='Text Attachment', attachment_type=allure.attachment_type.TEXT)\n    assert True\n\n# 3. behave.ini (optional, but good practice)\n# [behave]\n# format=allure_behave.formatter:AllureFormatter\n# outfiles=allure-results\n\n# 4. Run Behave tests and collect results\n# behave -f allure_behave.formatter:AllureFormatter -o allure-results features/\n\n# 5. Generate and open the Allure Report\n# allure serve allure-results","lang":"python","description":"This quickstart demonstrates how to integrate Allure Behave with a simple Behave feature file and step definitions. It includes an example of using `@allure.step` for sub-steps and `allure.attach` for adding content to the report. The `behave.ini` configuration is shown as an alternative to command-line arguments for specifying the Allure formatter. Finally, it shows how to generate and view the interactive Allure report using the Allure Report CLI tool."},"warnings":[{"fix":"Install the Allure Report CLI tool (e.g., `brew install allure` or follow official installation guides: `https://allurereport.org/docs/gettingstarted-installation/`).","message":"Generating the final HTML Allure Report requires the Allure Report command-line tool, which is a separate Java-based dependency and needs to be installed outside of Python (e.g., via Homebrew on macOS or manual download).","severity":"gotcha","affected_versions":"All versions"},{"fix":"For parallel execution, it's often necessary to integrate Allure Behave via `environment.py` hooks, calling `from allure_behave.hooks import allure_report` and then `allure_report('path/to/result/dir')` in appropriate `before_all` or `after_all` hooks. Consult `behavex` documentation for its specific Allure integration details.","message":"When running Behave tests in parallel (e.g., with `behave-parallel` or `behavex`), using the formatter directly (`-f allure_behave.formatter:AllureFormatter`) might be incompatible or lead to missing features.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `pip install allure-behave` has been successfully executed in the active Python environment. Verify the package is listed by `pip list`.","message":"The error `format=allure_behave.formatter:AllureFormatter is unknown` typically indicates that `allure-behave` is not correctly installed or not accessible in the Python environment where `behave` is being run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"As a workaround, avoid using `hide_excluded=true` or carefully inspect reports for incorrect step counts if this option is enabled. Check for official bug fixes in newer releases.","message":"Using `AllureFormatter.hide_excluded=true` with tag-excluded scenarios can lead to steps from the excluded scenarios incorrectly bleeding into the results of the next matching scenario.","severity":"gotcha","affected_versions":"2.15.3 (and potentially earlier/later until fixed)"},{"fix":"Upgrade to `allure-behave` 2.14.2 or newer to resolve these specific issues.","message":"Older versions (pre-2.14.2) could produce `AttributeError` if `Allure Behave` was set up via `AllureHooks` or generate extra test results after consecutive in-process runs of `Behave`.","severity":"breaking","affected_versions":"<2.14.2"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}