or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

formatter.mdhooks.mdindex.mdlistener.mdutils.md

index.mddocs/

0

# Allure Behave

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: allure-behave

7

- **Language**: Python

8

- **Installation**: `pip install allure-behave`

9

10

## Core Imports

11

12

```python

13

from allure_behave.formatter import AllureFormatter

14

from allure_behave.hooks import allure_report

15

```

16

17

## Basic Usage

18

19

### Formatter Integration (Standard)

20

21

Use the AllureFormatter directly with behave command line:

22

23

```bash

24

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

25

allure serve allure_results

26

```

27

28

### Hooks Integration (Parallel Support)

29

30

For parallel behave execution or custom environment setup, use the hooks integration in your `environment.py`:

31

32

```python

33

from allure_behave.hooks import allure_report

34

35

# Call this at module level in environment.py

36

allure_report("allure_results")

37

38

# Your existing before_all, after_all, etc. hooks will be automatically wrapped

39

def before_feature(context, feature):

40

# Your code here

41

pass

42

```

43

44

## Architecture

45

46

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

47

48

- **AllureFormatter**: Behave formatter that processes test execution events

49

- **AllureListener**: Core event processor that converts behave events to Allure reports

50

- **AllureHooks**: Hook-based integration for parallel execution scenarios

51

- **Utility Functions**: Helper functions for scenario/step processing and metadata extraction

52

53

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.

54

55

## Capabilities

56

57

### Formatter Integration

58

59

Primary integration method using Behave's formatter system. Provides direct command-line integration and automatic test result capture without code modifications.

60

61

```python { .api }

62

class AllureFormatter:

63

def __init__(self, stream_opener, config): ...

64

def uri(self, uri): ...

65

def feature(self, feature): ...

66

def step(self, step): ...

67

def match(self, match): ...

68

def result(self, result): ...

69

def eof(self): ...

70

def close(self): ...

71

def close_stream(self): ...

72

```

73

74

[Formatter Integration](./formatter.md)

75

76

### Hooks Integration

77

78

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.

79

80

```python { .api }

81

def allure_report(result_dir="allure_results"): ...

82

83

class AllureHooks:

84

def __init__(self, result_dir): ...

85

def after_all(self, context): ...

86

def before_feature(self, context, feature): ...

87

def after_feature(self, context, feature): ...

88

def before_scenario(self, context, scenario): ...

89

def after_scenario(self, context, scenario): ...

90

def before_step(self, context, step): ...

91

def after_step(self, context, step): ...

92

```

93

94

[Hooks Integration](./hooks.md)

95

96

### Test Event Processing

97

98

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.

99

100

```python { .api }

101

class AllureListener:

102

def __init__(self, behave_config): ...

103

def start_file(self): ...

104

def stop_feature(self): ...

105

def start_scenario(self, scenario): ...

106

def stop_scenario(self, scenario): ...

107

def schedule_step(self, step): ...

108

def match_step(self, match): ...

109

def start_behave_step(self, step): ...

110

def stop_behave_step(self, result): ...

111

```

112

113

[Event Processing](./listener.md)

114

115

### Utility Functions

116

117

Helper functions for processing behave scenarios, steps, and extracting metadata for Allure reports. Includes status conversion, parameter extraction, and test organization utilities.

118

119

```python { .api }

120

def scenario_name(scenario): ...

121

def scenario_history_id(scenario): ...

122

def scenario_parameters(scenario): ...

123

def scenario_links(scenario, issue_pattern, link_pattern): ...

124

def scenario_labels(scenario): ...

125

def step_status(result): ...

126

def get_fullname(scenario): ...

127

```

128

129

[Utilities](./utils.md)

130

131

## Configuration

132

133

Configuration options are passed through behave's userdata mechanism:

134

135

- **AllureFormatter.issue_pattern**: Pattern for formatting issue links from tags

136

- **AllureFormatter.link_pattern**: Pattern for formatting custom links from tags

137

- **AllureFormatter.hide_excluded**: Hide tests excluded by Allure test plan

138

139

## Test Plan Support

140

141

Allure Behave supports Allure test plan filtering to run only specific tests:

142

143

```python

144

# Tests not in the test plan will be skipped with reason "Not in allure test plan"

145

# Test plan integration uses scenario fullname and @allure.id tags for matching

146

```