pytest-testrail
pytest-testrail copied to clipboard
Issue getting "skipped" result to post to TestRail
Hi all,
I'm having issues getting a "skipped" pytest result to post to TestRail. pytest shows the status as "SKIPPED" but nothing is posted to TestRail. "Passed" and "failed" work just fine for me, but not any custom status such as "skipped".
This is the method I'm skipping:
@pytestrail.case('C1')
@pytest.mark.skip()
def test_C1():
# test code here
In my TestRail instance, I have created a custom status with Label = Skipped, status code/id = 6, and System Name = skipped. It is marked as a final status and is an active status.
Since the status code is different from the one hardcoded in pytest_testrail/plugin.py (it's hardcoded to 2, which in my TestRail instance is mapped to the "blocked" status), I edited (in my fork of this project) the dictionary PYTEST_TO_TESTRAIL_STATUS in pytest_testrail/plugin.py to:
PYTEST_TO_TESTRAIL_STATUS = { "passed": 1, "failed": 5, "skipped": 6, }
I'm not getting any errors, but it's still not posting anything to TestRail. My TestRail version is 5.4.1.3668.
EDIT: did a few more tests and discovered that it works if I skip the test like this:
@pytestrail.case('C1')
def test_C1():
pytest.skip()
...but not if I skip the test using the @pytest.mark.skip() marker.
Actually, if you use @pytest.mark.skip()
, the test will be skipped at the collection stage ("before" the tests execution). It's different from executing a test and skipping it along the way with pytest.skip()
.
I think what you want needs a new development, maybe in pytest_collectreport(report)
hook.
Agree with @apallier this is a new development, feel free to open a PR @jlin963
I think, that adding support for custom statuses ids chould be done in another issue