allankp / pytest-testrail

pytest plugin for integration with TestRail, for creating testruns and updating results
MIT License
95 stars 125 forks source link

Issue getting "skipped" result to post to TestRail #35

Open jlin963 opened 6 years ago

jlin963 commented 6 years ago

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. screen shot 2018-01-18 at 11 17 01 am

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.

apallier commented 6 years ago

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.

allankp commented 6 years ago

Agree with @apallier this is a new development, feel free to open a PR @jlin963

zeburek commented 6 years ago

I think, that adding support for custom statuses ids chould be done in another issue