diff --git a/conftest.py b/conftest.py index 4ea07bf..e1b102a 100644 --- a/conftest.py +++ b/conftest.py @@ -41,6 +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的值 @@ -56,6 +57,8 @@ 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", [])))) + _TOTAL = terminalreporter._numcollected @@ -75,9 +78,11 @@ def pytest_terminal_summary(terminalreporter, config): f"- 通过用例个数(passed): {_PASSED} 个\n" \ f"- 失败用例个数(failed): {_FAILED} 个\n" \ f"- 异常用例个数(error): {_ERROR} 个\n" \ - f"- 重跑的用例数(--reruns的值): {_RERUN} ({reruns_value}) 个\n" + f"- 重跑的用例数(--reruns的值): {_RERUN} ({reruns_value}) 个\n" \ + f"- 忽略(deselected)的用例数(使用-m忽略): {_DESELECTED} 个\n"\ + f"- 忽略(deselected)的用例:\n {deselected_cases}\n" try: - _RATE = (_PASSED + _XPASSED )/ (_PASSED + _FAILED + _XPASSED + _XFAILED) * 100 + _RATE = (_PASSED + _XPASSED) / (_PASSED + _FAILED + _XPASSED + _XFAILED) * 100 test_result = f"- 用例成功率: {_RATE:.2f} %\n" logger.success(f"{test_info}{test_result}") except ZeroDivisionError: diff --git a/interface/gitlink/test_api_account_login.yaml b/interface/gitlink/test_api_account_login.yaml index d1d8f82..17f9e5d 100644 --- a/interface/gitlink/test_api_account_login.yaml +++ b/interface/gitlink/test_api_account_login.yaml @@ -2,7 +2,7 @@ config: epic: GitLink接口 feature: 用户模块 story: 登录接口 - pytest_marker: + pytest_markers: - gitlink - smoke - login diff --git a/pytest.ini b/pytest.ini index baf8578..3d706d6 100644 --- a/pytest.ini +++ b/pytest.ini @@ -16,4 +16,5 @@ markers = gitea delete_project new_project - upload_file \ No newline at end of file + upload_file + login \ No newline at end of file