Skip to content

Commit baace11

Browse files
authored
use native name for scenario outlines (fixes #212 via #253)
1 parent 91a2926 commit baace11

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

allure-behave/features/scenario_outline.feature

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Feature: Scenario Outline
1515
"""
1616
When I run behave with allure formatter
1717

18-
Then allure report has a scenario with name "Scenario outline with one examples table"
18+
Then allure report has a scenario with name "Scenario outline with one examples table -- @1.1 examples table"
1919
And scenario contains step "Given simple passed step with param "Alice""
2020
And this scenario has parameter "user" with value "Alice"
2121

22-
Then allure report has a scenario with name "Scenario outline with one examples table"
22+
Then allure report has a scenario with name "Scenario outline with one examples table -- @1.2 examples table"
2323
And scenario contains step "Given simple passed step with param "Bob""
2424
And this scenario has parameter "user" with value "Bob"
2525

@@ -43,22 +43,22 @@ Feature: Scenario Outline
4343
"""
4444
When I run behave with allure formatter
4545

46-
Then allure report has a scenario with name "Scenario outline with many examples table"
46+
Then allure report has a scenario with name "Scenario outline with many examples table -- @1.1 first table"
4747
And scenario contains step "Given simple passed step with params "Peter I""
4848
And this scenario has parameter "parameter one" with value "Peter"
4949
And this scenario has parameter "parameter two" with value "I"
5050

51-
Then allure report has a scenario with name "Scenario outline with many examples table"
51+
Then allure report has a scenario with name "Scenario outline with many examples table -- @1.2 first table"
5252
And scenario contains step "Given simple passed step with params "Catherine II""
5353
And this scenario has parameter "parameter one" with value "Catherine"
5454
And this scenario has parameter "parameter two" with value "II"
5555

56-
Then allure report has a scenario with name "Scenario outline with many examples table"
56+
Then allure report has a scenario with name "Scenario outline with many examples table -- @2.1 second table"
5757
And scenario contains step "Given simple passed step with params "Richard the Lionheart""
5858
And this scenario has parameter "parameter one" with value "Richard"
5959
And this scenario has parameter "parameter two" with value "the Lionheart"
6060

61-
Then allure report has a scenario with name "Scenario outline with many examples table"
61+
Then allure report has a scenario with name "Scenario outline with many examples table -- @2.2 second table"
6262
And scenario contains step "Given simple passed step with params "Alexander the Great""
6363
And this scenario has parameter "parameter one" with value "Alexander"
6464
And this scenario has parameter "parameter two" with value "the Great"
@@ -88,18 +88,39 @@ Feature: Scenario Outline
8888
"""
8989
When I run behave with allure formatter
9090

91-
Then allure report has a scenario with name "First scenario outline in feature"
91+
Then allure report has a scenario with name "First scenario outline in feature -- @1.1 examples table"
9292
And scenario contains step "Given simple passed step with param "Rick""
9393
And this scenario has parameter "friend" with value "Rick"
9494

95-
Then allure report has a scenario with name "First scenario outline in feature"
95+
Then allure report has a scenario with name "First scenario outline in feature -- @1.2 examples table"
9696
And scenario contains step "Given simple passed step with param "Morty""
9797
And this scenario has parameter "friend" with value "Morty"
9898

99-
Then allure report has a scenario with name "Second scenario outline in feature"
99+
Then allure report has a scenario with name "Second scenario outline in feature -- @1.1 examples table"
100100
And scenario contains step "Given simple passed step with param "Finn""
101101
And this scenario has parameter "hero" with value "Finn"
102102

103-
Then allure report has a scenario with name "Second scenario outline in feature"
103+
Then allure report has a scenario with name "Second scenario outline in feature -- @1.2 examples table"
104104
And scenario contains step "Given simple passed step with param "Jack""
105105
And this scenario has parameter "hero" with value "Jack"
106+
107+
Scenario Outline: Scenario outline with one examples table
108+
Given feature definition
109+
"""
110+
Feature: Scenario Outline
111+
112+
Scenario Outline: Scenario outline with example variable <user> in name
113+
Given simple passed step with param "<user>"
114+
115+
Examples: examples table
116+
| user |
117+
| Alice |
118+
| Bob |
119+
"""
120+
When I run behave with allure formatter
121+
Then allure report has a scenario with name "Scenario outline with example variable <user> in name <postfix>"
122+
123+
Examples: examples table
124+
| user | postfix |
125+
| Alice | -- @1.1 examples table |
126+
| Bob | -- @1.2 examples table |

allure-behave/src/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import unicode_literals
33

44
from enum import Enum
5-
from behave.model import ScenarioOutline
65
from behave.runner_util import make_undefined_step_snippet
76
from allure_commons.types import Severity
87
from allure_commons.model2 import Status, Parameter
@@ -20,10 +19,6 @@
2019

2120

2221
def scenario_name(scenario):
23-
scenario_outlines = [so for so in scenario.feature if isinstance(so, ScenarioOutline)]
24-
current_scenario_outline = next(iter(filter(lambda so: scenario in so.scenarios, scenario_outlines)), None)
25-
if current_scenario_outline:
26-
return current_scenario_outline.name if current_scenario_outline.name else current_scenario_outline.keyword
2722
return scenario.name if scenario.name else scenario.keyword
2823

2924

allure-python-commons-test/src/report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
from hamcrest import has_property
7575
from hamcrest import has_item
7676
from hamcrest import has_entry
77-
from hamcrest import ends_with
77+
from hamcrest import ends_with, starts_with
7878
from hamcrest.core.base_matcher import BaseMatcher
7979

8080
if sys.version_info[0] < 3:
@@ -101,7 +101,7 @@ def has_test_case(name, *matchers):
101101
all_of(
102102
any_of(
103103
has_entry('fullName', ends_with(name)),
104-
has_entry('name', ends_with(name))
104+
has_entry('name', starts_with(name))
105105
),
106106
*matchers
107107
)

0 commit comments

Comments
 (0)