Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "testsolar-pytestx"
version = "0.1.54"
version = "0.1.55"
description = "Pytest tool for TestSolar"
authors = [
{name = "asiazhang2002", email = "asiazhang2002@gmail.com"},
Expand Down
24 changes: 24 additions & 0 deletions pytest/src/testsolar_pytestx/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
logger.info(f"Skipped {file}:{line}: {reason}")
test_result.Message = reason[:1000]

logger.info(f"{report.nodeid} setup result type: {result_type}")

elif report.when == "call":
test_result.Steps.append(
TestCaseStep(
Expand All @@ -150,6 +152,8 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:

test_result.ResultType = result_type

logger.info(f"{report.nodeid} call result type: {result_type}")

elif report.when == "teardown":
test_result.Steps.append(
TestCaseStep(
Expand All @@ -163,8 +167,24 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
if not test_result.is_final():
test_result.ResultType = result_type

logger.info(f"{report.nodeid} teardown result type: {result_type}")

logger.info(f"E {report.nodeid} log report")

def _correct_result_type(
self, steps: List[TestCaseStep], original_result_type: ResultType, testcase_name: str
) -> ResultType:
"""校正测试结果类型"""
result_type = original_result_type
for step in steps:
if step.ResultType == ResultType.FAILED and result_type == ResultType.SUCCEED:
logger.info(
f"{testcase_name} result type corrected to FAILED due to failed step: {step.Title}"
)
result_type = ResultType.FAILED
break
return result_type

def pytest_runtest_logfinish(self, nodeid: str, location: Any) -> None:
"""
Called at the end of running the runtest protocol for a single item.
Expand All @@ -174,6 +194,10 @@ def pytest_runtest_logfinish(self, nodeid: str, location: Any) -> None:

test_result = self.testdata[testcase_name]
test_result.EndTime = datetime.utcnow()
# 上报前预先校正一遍测试结果
test_result.ResultType = self._correct_result_type(
test_result.Steps, test_result.ResultType, testcase_name
)
self.testcase_count += 1
logger.info(
f"Testcase {nodeid} finished with result type {test_result.ResultType}, total {self.testcase_count} testcases complete"
Expand Down
2 changes: 1 addition & 1 deletion pytest/testtool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ schemaVersion: 1.0
name: pytest
nameZh: pytest自动化测试
lang: python
version: '0.1.54'
version: '0.1.55'
langType: INTERPRETED
description: |-
pytest是一个成熟的全功能Python测试工具,可以帮助您编写更好的程序。此测试工具允许您在TestSolar上运行pytest。
Expand Down