Skip to content

Commit 69905e7

Browse files
authored
add epic label (fixes #85 via #90)
1 parent 51dedf9 commit 69905e7

File tree

8 files changed

+89
-25
lines changed

8 files changed

+89
-25
lines changed

allure-pytest/src/plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ def a_label_type(string):
3838
Tests only with these severities will be run.
3939
Possible values are: %s.""" % ', '.join(severities))
4040

41+
parser.getgroup("general").addoption('--allure-epics',
42+
action="store",
43+
dest="allure_epics",
44+
metavar="EPICS_SET",
45+
default={},
46+
type=label_type(name=LabelType.EPIC),
47+
help="""Comma-separated list of epic names.
48+
Run tests that have at least one of the specified feature labels.""")
49+
4150
parser.getgroup("general").addoption('--allure-features',
4251
action="store",
4352
dest="allure_features",
Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
>>> allure_report = getfixture('allure_report_with_params')('--allure-features=right_feature',
2+
>>> allure_report = getfixture('allure_report_with_params')('--allure-epic=right_epic',
3+
... '--allure-features=right_feature',
34
... '--allure-stories=right_story')
45
>>> assert_that(allure_report,
56
... all_of(
@@ -8,57 +9,84 @@
89
... )) # doctest: +SKIP
910
"""
1011

11-
import pytest
12+
import allure
1213

13-
def test_wihtout_features_and_stories():
14+
15+
def test_without_epic_features_and_stories():
1416
"""
15-
>>> allure_report = getfixture('allure_report_with_params')('--allure-features=right_feature',
17+
>>> allure_report = getfixture('allure_report_with_params')('--allure-epic=right_epic',
18+
... '--allure-features=right_feature',
1619
... '--allure-stories=right_story')
1720
>>> assert_that(allure_report,
18-
... has_test_case('test_wihtout_features_and_stories',
21+
... has_test_case('test_without_epic_features_and_stories',
1922
... with_status('skipped')
2023
... )
2124
... )
2225
"""
2326
pass
2427

25-
@pytest.allure.feature('right_feature')
26-
def test_right_feature_without_story():
28+
29+
@allure.feature('right_feature')
30+
def test_right_feature_without_story_and_epic():
2731
"""
28-
>>> allure_report = getfixture('allure_report_with_params')('--allure-features=right_feature',
32+
>>> allure_report = getfixture('allure_report_with_params')('--allure-epic=right_epic',
33+
... '--allure-features=right_feature',
2934
... '--allure-stories=right_story')
3035
>>> assert_that(allure_report,
31-
... has_test_case('test_right_feature_without_story',
36+
... has_test_case('test_right_feature_without_story_and_epic',
3237
... with_status('passed')
3338
... )
3439
... )
3540
"""
3641
pass
3742

38-
@pytest.allure.feature('wrong_feature')
39-
@pytest.allure.story('right_story')
40-
def test_wrong_feature_and_right_story():
43+
44+
@allure.feature('wrong_epic')
45+
@allure.feature('wrong_feature')
46+
@allure.story('right_story')
47+
def test_right_story_but_wrong_epic_and_feature():
4148
"""
42-
>>> allure_report = getfixture('allure_report_with_params')('--allure-features=right_feature',
49+
>>> allure_report = getfixture('allure_report_with_params')('--allure-epic=right_epic',
50+
... '--allure-features=right_feature',
4351
... '--allure-stories=right_story')
4452
>>> assert_that(allure_report,
45-
... has_test_case('test_wrong_feature_and_right_story',
53+
... has_test_case('test_right_story_but_wrong_epic_and_feature',
4654
... with_status('passed')
4755
... )
4856
... )
4957
"""
5058
pass
5159

52-
@pytest.allure.feature('right_feature')
53-
@pytest.allure.story('wrong_story')
54-
def test_right_feature_and_wrong_story():
60+
61+
@allure.feature('wrong_epic')
62+
@allure.feature('right_feature')
63+
@allure.story('wrong_story')
64+
def test_right_feature_but_wrong_epic_and_story():
5565
"""
56-
>>> allure_report = getfixture('allure_report_with_params')('--allure-features=right_feature',
66+
>>> allure_report = getfixture('allure_report_with_params')('--allure-epic=right_epic',
67+
... '--allure-features=right_feature',
5768
... '--allure-stories=right_story')
5869
>>> assert_that(allure_report,
59-
... has_test_case('test_right_feature_and_wrong_story',
70+
... has_test_case('test_right_feature_but_wrong_epic_and_story',
6071
... with_status('passed')
6172
... )
6273
... )
6374
"""
6475
pass
76+
77+
78+
@allure.feature('wrong_epic')
79+
@allure.feature('wrong_feature')
80+
@allure.story('wrong_story')
81+
def test_wrong_epic_feature_and_story():
82+
"""
83+
>>> allure_report = getfixture('allure_report_with_params')('--allure-epic=right_epic',
84+
... '--allure-features=right_feature',
85+
... '--allure-stories=right_story')
86+
>>> assert_that(allure_report,
87+
... has_test_case('test_wrong_epic_feature_and_story',
88+
... with_status('skipped')
89+
... )
90+
... )
91+
"""
92+
pass

allure-pytest/test/labels/function_bdd_labels_test.py renamed to allure-pytest/test/labels/bdd/function_bdd_labels_test.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,22 @@
77
... )) # doctest: +SKIP
88
"""
99

10-
import pytest
10+
import allure
1111

1212

13-
@pytest.allure.feature('single feature')
13+
@allure.epic('single epic')
14+
def test_single_epic_label():
15+
"""
16+
>>> allure_report = getfixture('allure_report')
17+
>>> assert_that(allure_report,
18+
... has_test_case('test_single_epic_label',
19+
... has_epic('single epic')
20+
... ))
21+
"""
22+
pass
23+
24+
25+
@allure.feature('single feature')
1426
def test_single_feature_label():
1527
"""
1628
>>> allure_report = getfixture('allure_report')
@@ -22,7 +34,7 @@ def test_single_feature_label():
2234
pass
2335

2436

25-
@pytest.allure.story('single story')
37+
@allure.story('single story')
2638
def test_single_story_label():
2739
"""
2840
>>> allure_report = getfixture('allure_report')
@@ -34,14 +46,17 @@ def test_single_story_label():
3446
pass
3547

3648

37-
@pytest.allure.feature('feature one', 'feature two')
38-
@pytest.allure.story('story one', 'story two')
49+
@allure.epic('epic one', 'epic two')
50+
@allure.feature('feature one', 'feature two')
51+
@allure.story('story one', 'story two')
3952
def test_many_bdd_labels_for_one_function():
4053
"""
4154
>>> allure_report = getfixture('allure_report')
4255
>>> assert_that(allure_report,
4356
... has_test_case('test_many_bdd_labels_for_one_function',
4457
... all_of(
58+
... has_epic('epic one'),
59+
... has_epic('epic two'),
4560
... has_feature('feature one'),
4661
... has_feature('feature two'),
4762
... has_story('story one'),

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def has_severity(level):
2020
return has_label('severity', level)
2121

2222

23+
def has_epic(feature):
24+
return has_label('epic', feature)
25+
26+
2327
def has_feature(feature):
2428
return has_label('feature', feature)
2529

allure-python-commons/allure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from allure_commons._allure import label
2-
from allure_commons._allure import severity, tag, feature, story
2+
from allure_commons._allure import severity
3+
from allure_commons._allure import tag
4+
from allure_commons._allure import epic, feature, story
35
from allure_commons._allure import link
46
from allure_commons._allure import issue, testcase
57
from allure_commons._allure import Dynamic as dynamic
@@ -13,6 +15,7 @@
1315
'label',
1416
'severity',
1517
'tag',
18+
'epic'
1619
'feature',
1720
'story',
1821

allure-python-commons/src/_allure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def severity(severity_level):
2323
return label(LabelType.SEVERITY, severity_level)
2424

2525

26+
def epic(*epics):
27+
return label(LabelType.EPIC, *epics)
28+
29+
2630
def feature(*features):
2731
return label(LabelType.FEATURE, *features)
2832

allure-python-commons/src/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class LinkType(object):
1818

1919

2020
class LabelType(str, Enum):
21+
EPIC = 'epic'
2122
FEATURE = 'feature'
2223
STORY = 'story'
2324
SEVERITY = 'severity'

0 commit comments

Comments
 (0)