【问题标题】:Pytest Testrail Module - Post Test Results for Test RunsPytest Testrail 模块 - 发布测试运行的测试结果
【发布时间】:2017-09-18 20:42:51
【问题描述】:

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

import pytest
from pytest_testrail.plugin import testrail

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

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

【问题讨论】:

    标签: python pytest testrail


    【解决方案1】:

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

    import pytest
    from pytest_testrail.plugin import testrail
    
    @testrail('C165')
    def test_run():
        assert False
    

    【讨论】:

      【解决方案2】:

      这里是add_result 函数。 testrail 插件会在您的测试 (test_run) 完成时执行它。

      您可以注意到函数中的参数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.
          """
      

      【讨论】:

        猜你喜欢
        • 2019-11-27
        • 1970-01-01
        • 2019-02-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-25
        • 1970-01-01
        • 2022-11-30
        相关资源
        最近更新 更多