Skip to content

Commit 5e7bc86

Browse files
authored
Fixed tests filter by ID and selectors (via #546)
1 parent 6e7fe49 commit 5e7bc86

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

allure-robotframework/src/listener/allure_testplan.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@
88
class allure_testplan(SuiteVisitor):
99
def __init__(self):
1010
self.testplan = get_testplan()
11+
self.allure_ids = [test["id"] for test in self.testplan] if self.testplan else []
12+
self.selectors = [test["selector"] for test in self.testplan] if self.testplan else []
1113

1214
def start_suite(self, suite):
1315
if self.testplan:
14-
# included_tests = [test["selector"] for test in self.testplan]
15-
included_tests = self.included_tests(suite)
16-
if included_tests:
17-
suite.filter(included_tests=self.included_tests(suite))
16+
suite.tests = self.included_tests(suite)
1817

1918
def included_tests(self, suite):
2019
included_tests = []
20+
2121
for test in suite.tests:
2222
allure_id = None
2323
for label in allure_labels(test.tags):
2424
if label.name == LabelType.ID:
2525
allure_id = str(label.value)
26-
if allure_id and any([allure_id == item.get("id", None) for item in self.testplan]):
27-
included_tests.append(test.name)
26+
if allure_id and allure_id in self.allure_ids:
27+
included_tests.append(test)
28+
elif test.longname in self.selectors:
29+
included_tests.append(test)
30+
31+
return included_tests
2832

29-
return included_tests or [test["selector"] for test in self.testplan]
33+
def end_suite(self, suite):
34+
suite.suites = [s for s in suite.suites if s.test_count > 0]

0 commit comments

Comments
 (0)