Pytest Testrail模块 - 测试运行的测试结果

时间:2017-09-18 20:42:51

标签: python pytest testrail

我正在尝试使用pytest testrail模块并从这个演示脚本开始:

import pytest
from pytest_testrail.plugin import testrail

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

它确实会创建一个测试运行,但不会将任何结果发布到相应的测试用例。

2 个答案:

答案 0 :(得分:1)

尝试添加一个断言,因为这是pytest钩子所要寻找的:

import pytest
from pytest_testrail.plugin import testrail

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

答案 1 :(得分:0)

这是add_result函数。测试(test_run)完成后,testrail插件将执行它。

您会注意到函数中的参数status,它要求您的测试需要从断言中返回结果(例如assert False是一个很好的例子)。

对于您而言,仅打印字符串不利于testrail知道测试的状态。

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.
    """
相关问题