or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

formatter.mdhooks.mdindex.mdlistener.mdutils.md
tile.json

tessl/pypi-allure-behave

Allure behave integration that provides comprehensive test reporting and visualization for the Behave BDD testing framework

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/allure-behave@2.15.x

To install, run

npx @tessl/cli install tessl/pypi-allure-behave@2.15.0

index.mddocs/

Allure Behave

Allure 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.

Package Information

  • Package Name: allure-behave
  • Language: Python
  • Installation: pip install allure-behave

Core Imports

from allure_behave.formatter import AllureFormatter
from allure_behave.hooks import allure_report

Basic Usage

Formatter Integration (Standard)

Use the AllureFormatter directly with behave command line:

behave -f allure_behave.formatter:AllureFormatter -o allure_results ./features
allure serve allure_results

Hooks Integration (Parallel Support)

For 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
    pass

Architecture

Allure Behave implements a multi-layer architecture for comprehensive test reporting:

  • AllureFormatter: Behave formatter that processes test execution events
  • AllureListener: Core event processor that converts behave events to Allure reports
  • AllureHooks: Hook-based integration for parallel execution scenarios
  • Utility Functions: Helper functions for scenario/step processing and metadata extraction

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.

Capabilities

Formatter Integration

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): ...

Formatter Integration

Hooks Integration

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): ...

Hooks Integration

Test Event Processing

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): ...

Event Processing

Utility Functions

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): ...

Utilities

Configuration

Configuration options are passed through behave's userdata mechanism:

  • AllureFormatter.issue_pattern: Pattern for formatting issue links from tags
  • AllureFormatter.link_pattern: Pattern for formatting custom links from tags
  • AllureFormatter.hide_excluded: Hide tests excluded by Allure test plan

Test Plan Support

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