增加重试用例统计
This commit is contained in:
parent
ef61a029d1
commit
219fa1c91e
|
@ -16,6 +16,7 @@ class TestMetrics:
|
|||
""" 用例结果数据 """
|
||||
total: int
|
||||
passed: int
|
||||
rerun: int
|
||||
failed: int
|
||||
skipped: int
|
||||
xfailed: int
|
||||
|
|
|
@ -61,6 +61,7 @@ email_content = """
|
|||
执行结果如下:<br>
|
||||
用例运行总数:<strong> ${total}条</strong><br>
|
||||
通过用例数(passed): <strong><font color="green" >${passed}条</font></strong><br>
|
||||
重试通过用例数(rerun): <strong><font color="green" >${rerun}条</font></strong><br>
|
||||
失败用例数(failed): <strong><font color="red" >${failed}条</font></strong><br>
|
||||
报错用例数(error): <strong><font color="orange" >${error}条</font></strong><br>
|
||||
跳过用例数(skipped): <strong><font color="grey" >${skipped}条</font></strong><br>
|
||||
|
@ -86,6 +87,7 @@ wechat_content = """******用例执行结果统计******
|
|||
> 测试环境:%s
|
||||
> 总用例数:<font color=\"info\">${total}条</font>
|
||||
> 通过用例数:<font color=\"info\">${passed}条</font>
|
||||
> 重试通过用例数:<font color=\"info\">${rerun}条</font>
|
||||
> 失败用例数:<font color=\"red\">${failed}条</font>
|
||||
> 报错用例数:<font color=\"red\">${error}条</font>
|
||||
> 跳过用例数:<font color=\"warning\">${skipped}条</font>
|
||||
|
|
|
@ -82,6 +82,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
|
|||
print("******用例执行结果统计******")
|
||||
print(f"总用例数:{pytest_result.total}条")
|
||||
print(f"通过:{pytest_result.passed}条")
|
||||
print(f"重试后通过:{pytest_result.rerun}条")
|
||||
print(f"失败:{pytest_result.failed}条")
|
||||
print(f"跳过:{pytest_result.skipped}条")
|
||||
print(f"预期失败:{pytest_result.xfailed}条")
|
||||
|
|
|
@ -29,6 +29,7 @@ class ReportDataHandle:
|
|||
case_count["total"] = pytest_result['summary'].get("total", 0) # 用例总数
|
||||
case_count["passed"] = pytest_result["summary"].get("passed", 0) # 通过用例数
|
||||
case_count["failed"] = pytest_result["summary"].get("failed", 0) # 失败用例数
|
||||
case_count["rerun"] = pytest_result["summary"].get("rerun", 0) # 重试通过用例数
|
||||
case_count["skipped"] = pytest_result["summary"].get("skipped", 0) # 跳过用例数
|
||||
case_count["xfailed"] = pytest_result["summary"].get("xfailed", 0) # 预期失败用例数
|
||||
case_count["xpassed"] = pytest_result["summary"].get("xpassed", 0) # 预期成功用例数
|
||||
|
@ -37,7 +38,7 @@ class ReportDataHandle:
|
|||
if case_count["total"] > 0:
|
||||
# 计算成功率
|
||||
case_count["pass_rate"] = round(
|
||||
(case_count["passed"] + case_count["xpassed"]) / case_count["total"] * 100, 2)
|
||||
(case_count["passed"] + case_count["rerun"] + case_count["xpassed"]) / case_count["total"] * 100, 2)
|
||||
else:
|
||||
# 如果未运行用例,则成功率为 0.0
|
||||
case_count["pass_rate"] = 0.0
|
||||
|
|
Loading…
Reference in New Issue