Context Attributes¶
A context object (Context
) is handed to
step definitions (step implementations)
behave hooks (
before_all()
,before_feature()
, …,after_all()
)
Behave Attributes¶
The behave runner assigns a number of attributes to the context object during a test run.
Attribute Name |
Layer |
Type |
Description |
---|---|---|---|
config |
test run |
|
Configuration that is used. |
aborted |
test run |
bool |
Set to true if test run is aborted by the user. |
failed |
test run |
bool |
Set to true if a step fails. |
feature |
feature |
Current feature. |
|
rule |
rule |
Current rule. |
|
tags |
feature, rule, scenario |
list< |
Effective tags of current feature, rule, scenario, scenario outline. |
active_outline |
scenario outline |
Current row in a scenario outline (in examples table). |
|
scenario |
scenario |
Current scenario. |
|
log_capture |
scenario |
If logging capture is enabled. |
|
stdout_capture |
scenario |
|
If stdout capture is enabled. |
stderr_capture |
scenario |
|
If stderr capture is enabled. |
table |
step |
Contains step’s table, otherwise None. |
|
text |
step |
String |
Contains step’s multi-line text (unicode), otherwise None. |
Note
Behave attributes in the context object should not be modified by a user.
See Context
class description for more details.
User Attributes¶
A user can assign (or modify) own attributes to the context object. But these attributes will be removed again from the context object depending where these attributes are defined.
Kind |
Assign Location |
Lifecycle Layer (Scope) |
---|---|---|
Hook |
|
test run |
Hook |
|
test run |
Hook |
|
feature, rule or scenario |
Hook |
|
feature, rule or scenario |
Hook |
|
feature |
Hook |
|
feature |
Hook |
|
rule |
Hook |
|
rule |
Hook |
|
scenario |
Hook |
|
scenario |
Hook |
|
scenario |
Hook |
|
scenario |
Step |
Step definition |
scenario |