更新conftest.py中测试用例统计情况
This commit is contained in:
21
conftest.py
21
conftest.py
@@ -41,7 +41,7 @@ def pytest_terminal_summary(terminalreporter, config):
|
||||
"""
|
||||
收集测试结果
|
||||
"""
|
||||
deselected_cases = "\n".join(list(map(str, terminalreporter.stats.get("deselected", []))))
|
||||
|
||||
_RERUN = len([i for i in terminalreporter.stats.get('rerun', []) if i.when != 'teardown'])
|
||||
try:
|
||||
# 获取pytest传参--reruns的值
|
||||
@@ -57,10 +57,10 @@ def pytest_terminal_summary(terminalreporter, config):
|
||||
_SKIPPED = len([i for i in terminalreporter.stats.get('skipped', []) if i.when != 'teardown'])
|
||||
_XPASSED = len([i for i in terminalreporter.stats.get('xpassed', []) if i.when != 'teardown'])
|
||||
_XFAILED = len([i for i in terminalreporter.stats.get('xfailed', []) if i.when != 'teardown'])
|
||||
_DESELECTED = len(list(map(str, terminalreporter.stats.get("deselected", []))))
|
||||
_DESELECTED = len(terminalreporter.stats.get('deselected', []))
|
||||
deselected_cases = "\n".join(list(map(str, terminalreporter.stats.get("deselected", []))))
|
||||
|
||||
|
||||
_TOTAL = terminalreporter._numcollected
|
||||
_TOTAL = _PASSED + _ERROR + _FAILED + _SKIPPED + _XPASSED + _XFAILED + _DESELECTED
|
||||
|
||||
_DURATION = time.time() - terminalreporter._sessionstarttime
|
||||
|
||||
@@ -72,15 +72,18 @@ def pytest_terminal_summary(terminalreporter, config):
|
||||
f"自动化用例于 {_START_TIME}- 开始运行,运行时长:{_DURATION:.2f} s, 目前已执行完成。\n" \
|
||||
f"--------------------------------------\n" \
|
||||
f"#### 执行结果如下:\n" \
|
||||
f"- 用例运行总数: {_TOTAL} 个\n" \
|
||||
f"- 跳过用例个数(skipped): {_SKIPPED} 个\n" \
|
||||
f"- 测试用例总数: {_TOTAL} 个\n" \
|
||||
f"- 跳过用例个数(skipped+deselected): {_SKIPPED + _DESELECTED} 个\n" \
|
||||
f"- 实际执行用例总数: {_PASSED + _FAILED + _XPASSED + _XFAILED} 个\n" \
|
||||
f"--------------------------------------------------------------\n" \
|
||||
f"- 通过用例个数(passed): {_PASSED} 个\n" \
|
||||
f"- 失败用例个数(failed): {_FAILED} 个\n" \
|
||||
f"- 异常用例个数(error): {_ERROR} 个\n" \
|
||||
f"- 重跑的用例数(--reruns的值): {_RERUN} ({reruns_value}) 个\n" \
|
||||
f"- 忽略(deselected)的用例数(使用-m忽略): {_DESELECTED} 个\n"\
|
||||
f"- 忽略(deselected)的用例:\n {deselected_cases}\n"
|
||||
f"- 重跑的用例数(--reruns的值): {_RERUN} 个 ({reruns_value})\n" \
|
||||
f"--------------------------------------------------------------\n" \
|
||||
f"- 忽略(deselected)的用例:\n{deselected_cases}\n" \
|
||||
f"--------------------------------------------------------------\n"
|
||||
|
||||
try:
|
||||
_RATE = (_PASSED + _XPASSED) / (_PASSED + _FAILED + _XPASSED + _XFAILED) * 100
|
||||
test_result = f"- 用例成功率: {_RATE:.2f} %\n"
|
||||
|
||||
Reference in New Issue
Block a user