如何重新运行测试失败的Python Webdriver测试?

2024-04-29 09:14:13 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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


Tags: unittestwebdriverflaky
1条回答
网友
1楼 · 发布于 2024-04-29 09:14:13

能够解决这个问题。在

下面是相同的示例代码:

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())

如果测试用例中有一个失败或错误,测试套件将再次执行。在

相关问题 更多 >