【问题标题】:How to rerun failed test Python Webdriver test?如何重新运行失败的测试 Python Webdriver 测试?
【发布时间】:2016-11-26 15:07:23
【问题描述】:

我无法重新运行失败的 python webdriver 测试。我正在使用 unittest 进行测试执行。

已尝试使用flaky,但未成功。

【问题讨论】:

  • 删除了不必要的介绍和结束。

标签: python webdriver


【解决方案1】:

能够解决这个问题。

以下是相同的示例代码:

import HTMLTestRunner
import os
import unittest

def testsuite():
    suite = unittest.TestSuite()
    suite.addTest("Add your test here")


    return suite

reportloc = os.getcwd()
outfile = open(reportloc + "TestReport.html", "w")
executor = HTMLTestRunner.HTMLTestRunner(stream=outfile, title="Test Report", description="Tests")

envresult = executor.run(testsuite())
if envresult.error_count >= 1 or envresult.failure_count >= 1:
    executor.run(testsuite())

如果任一测试用例出现故障或错误,测试套件将再次执行。

【讨论】:

    最近更新 更多