Pytest Testrail Module - Post Test Results for Test Runs

我的未来我决定 提交于 2020-06-18 13:41:52

问题


I am trying to use the pytest testrail module and started with this demo script:

import pytest
from pytest_testrail.plugin import testrail

@testrail('C165')
def test_run():
    print "T165:pass"

It does create a test run but does not post any results to the corresponding test cases.


回答1:


Try adding an assertion as that is what the pytest hook is looking for:

import pytest
from pytest_testrail.plugin import testrail

@testrail('C165')
def test_run():
    assert False



回答2:


Here is add_result function. The testrail plugin executes it when your test (test_run) is finished.

You can notice the parameter status in the function, it requires your test need to return the result from assertion (ex. assert False is good example).

In your case, just print a string is not good to testrail know the status of the test.

def add_result(self, test_ids, status, comment='', duration=0):
    """
    Add a new result to results dict to be submitted at the end.

    :param list test_ids: list of test_ids.
    :param int status: status code of test (pass or fail).
    :param comment: None or a failure representation.
    :param duration: Time it took to run just the test.
    """


来源:https://stackoverflow.com/questions/46287899/pytest-testrail-module-post-test-results-for-test-runs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!