Allure behave integration that provides comprehensive test reporting and visualization for the Behave BDD testing framework
npx @tessl/cli install tessl/pypi-allure-behave@2.15.0Allure Behave provides comprehensive test reporting and visualization for the Behave BDD (Behavior-Driven Development) testing framework. It integrates with the Allure Report ecosystem to generate detailed HTML reports with test execution data, step results, attachments, and historical trends.
pip install allure-behavefrom allure_behave.formatter import AllureFormatter
from allure_behave.hooks import allure_reportUse the AllureFormatter directly with behave command line:
behave -f allure_behave.formatter:AllureFormatter -o allure_results ./features
allure serve allure_resultsFor parallel behave execution or custom environment setup, use the hooks integration in your environment.py:
from allure_behave.hooks import allure_report
# Call this at module level in environment.py
allure_report("allure_results")
# Your existing before_all, after_all, etc. hooks will be automatically wrapped
def before_feature(context, feature):
# Your code here
passAllure Behave implements a multi-layer architecture for comprehensive test reporting:
The integration works by intercepting behave's test execution lifecycle events and converting them into Allure's standardized reporting format, enabling rich visualization and analysis capabilities.
Primary integration method using Behave's formatter system. Provides direct command-line integration and automatic test result capture without code modifications.
class AllureFormatter:
def __init__(self, stream_opener, config): ...
def uri(self, uri): ...
def feature(self, feature): ...
def step(self, step): ...
def match(self, match): ...
def result(self, result): ...
def eof(self): ...
def close(self): ...
def close_stream(self): ...Alternative integration method using behave hooks for parallel execution support and custom environment setups. Enables Allure reporting in scenarios where the formatter approach is insufficient.
def allure_report(result_dir="allure_results"): ...
class AllureHooks:
def __init__(self, result_dir): ...
def after_all(self, context): ...
def before_feature(self, context, feature): ...
def after_feature(self, context, feature): ...
def before_scenario(self, context, scenario): ...
def after_scenario(self, context, scenario): ...
def before_step(self, context, step): ...
def after_step(self, context, step): ...Core listener that handles test execution events and converts them to Allure report data. Supports scenario processing, step tracking, attachments, and metadata extraction from behave test elements.
class AllureListener:
def __init__(self, behave_config): ...
def start_file(self): ...
def stop_feature(self): ...
def start_scenario(self, scenario): ...
def stop_scenario(self, scenario): ...
def schedule_step(self, step): ...
def match_step(self, match): ...
def start_behave_step(self, step): ...
def stop_behave_step(self, result): ...Helper functions for processing behave scenarios, steps, and extracting metadata for Allure reports. Includes status conversion, parameter extraction, and test organization utilities.
def scenario_name(scenario): ...
def scenario_history_id(scenario): ...
def scenario_parameters(scenario): ...
def scenario_links(scenario, issue_pattern, link_pattern): ...
def scenario_labels(scenario): ...
def step_status(result): ...
def get_fullname(scenario): ...Configuration options are passed through behave's userdata mechanism:
Allure Behave supports Allure test plan filtering to run only specific tests:
# Tests not in the test plan will be skipped with reason "Not in allure test plan"
# Test plan integration uses scenario fullname and @allure.id tags for matching