Skip to content

Commit c187d6a

Browse files
committed
Add behave test case for dynamic description
1 parent 142d790 commit c187d6a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

allure-behave/features/description.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,24 @@ Feature: Description
1313
"""
1414
When I run behave with allure formatter
1515
Then allure report has a scenario with name "Scenario with description"
16+
17+
Scenario: Dynamic description
18+
Given feature definition
19+
"""
20+
Feature: Step status
21+
22+
Scenario: Scenario with passed step
23+
Given simple passed step
24+
"""
25+
And hooks implementation
26+
"""
27+
import allure
28+
import allure_commons
29+
30+
@allure_commons.fixture
31+
def before_scenario(context, scenario):
32+
allure.dynamic.description("Test description")
33+
"""
34+
When I run behave with allure formatter
35+
Then allure report has a scenario with name "Scenario with passed step"
36+
And scenario has description "Test description"

allure-behave/features/steps/report_steps.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import partial
2-
from hamcrest import assert_that
2+
from hamcrest import assert_that, contains_string
33
from hamcrest import not_
44
from allure_commons_test.report import has_test_case
55
from allure_commons_test.result import with_status
@@ -9,6 +9,7 @@
99
from allure_commons_test.result import has_status_details
1010
from allure_commons_test.result import with_message_contains
1111
from allure_commons_test.result import has_link
12+
from allure_commons_test.result import has_description
1213
from allure_commons_test.container import has_container
1314
from allure_commons_test.container import has_before, has_after
1415
from allure_commons_test.label import has_severity
@@ -149,3 +150,10 @@ def step_attachment(context, item):
149150
context_matcher = getattr(context, item)
150151
matcher = partial(context_matcher, has_attachment)
151152
assert_that(context.allure_report, matcher())
153+
154+
155+
@then(u'scenario has description "{description}"')
156+
def step_description(context, description):
157+
context_matcher = context.scenario
158+
matcher = partial(context_matcher, has_description, contains_string(description))
159+
assert_that(context.allure_report, matcher())

0 commit comments

Comments
 (0)