forked from allure-framework/allure-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
select tests by testcase id (via allure-framework#417)
- Loading branch information
1 parent
36f133a
commit 4a66122
Showing
4 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
allure-pytest/test/integration/allure_ee/select_by_testcase_id_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import pytest | ||
import json | ||
import os | ||
from hamcrest import assert_that, only_contains, any_of, ends_with | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["ids", "expected_tests"], | ||
[ | ||
( | ||
["1", "2"], | ||
["test_number_one", "test_number_two"] | ||
), | ||
( | ||
["1", "3", "3+"], | ||
["test_number_one", "test_number_three"] | ||
), | ||
( | ||
None, | ||
["test_number_one", "test_number_two", "test_number_three", "test_without_number"] | ||
), | ||
] | ||
) | ||
def test_select_by_testcase_id_test(ids, expected_tests, allured_testdir): | ||
""" | ||
>>> import allure | ||
>>> @allure.id("1") | ||
... def test_number_one(): | ||
... pass | ||
>>> @allure.id("2") | ||
... def test_number_two(): | ||
... pass | ||
>>> @allure.id("3") | ||
... @allure.id("3+") | ||
... def test_number_three(): | ||
... pass | ||
>>> def test_without_number(): | ||
... pass | ||
""" | ||
allured_testdir.parse_docstring_source() | ||
|
||
if ids: | ||
py_path = allured_testdir.testdir.makefile(".json", json.dumps(ids)) | ||
os.environ["AS_TESTPLAN_PATH"] = py_path.strpath | ||
else: | ||
del os.environ["AS_TESTPLAN_PATH"] | ||
|
||
allured_testdir.run_with_allure() | ||
test_cases = [test_case["fullName"] for test_case in allured_testdir.allure_report.test_cases] | ||
assert_that(test_cases, only_contains( | ||
any_of( | ||
*[ends_with(name) for name in expected_tests] | ||
) | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters