feat: add shared test acceptance and release 1.5.0
This commit is contained in:
1 parent
3fbcdfefea
commit
ec2c1265d3
35 files changed
+826
-51
No files matched your search
@@ -23,6 +23,7 @@ from apps.admin_console.database.repositories.session_repository import SessionR
|
||||
from apps.admin_console.database.repositories.step_repository import StepRepository
|
||||
from apps.admin_console.services.automation_store import store, identifier
|
||||
from apps.admin_console.services.task_import import execution_title
|
||||
from artemis.runtime.case_result import RESULT_LABELS, resolve_case_result
|
||||
|
||||
EXPORT_ROOT = WORKSPACE_ROOT / "artifacts" / "reports"
|
||||
EXPORT_LOCK = threading.RLock()
|
||||
@@ -62,6 +63,9 @@ def text(value) -> str:
|
||||
|
||||
|
||||
def verdict(outcome: dict | None) -> str:
|
||||
result = (outcome or {}).get("test_result")
|
||||
if isinstance(result, dict) and result.get("status") in RESULT_LABELS:
|
||||
return RESULT_LABELS[result["status"]]
|
||||
tests = (outcome or {}).get("tests") or {}
|
||||
if tests.get("failed", 0):
|
||||
return "验证失败"
|
||||
@@ -179,6 +183,9 @@ def session_report(session_id: str, db_path=None) -> dict:
|
||||
case = meta.get("case") or {}
|
||||
status = meta.get("terminal_status") or meta.get("status") or session.get("status", "unknown")
|
||||
error = failure_reason(directory, status, meta.get("error"))
|
||||
test_result = resolve_case_result(outcome, status, error)
|
||||
if test_result:
|
||||
outcome = {**outcome, "test_result": test_result.model_dump()}
|
||||
verification = verdict(outcome)
|
||||
if status in {"failed", "interrupted"} and verification.startswith("未验证"):
|
||||
verification = "未验证(任务异常终止)"
|
||||
@@ -197,6 +204,7 @@ def session_report(session_id: str, db_path=None) -> dict:
|
||||
"expected": case.get("expected", ""),
|
||||
"status": status,
|
||||
"verdict": verification,
|
||||
"test_result": test_result.model_dump() if test_result else None,
|
||||
"outcome": outcome,
|
||||
"content": content,
|
||||
"steps": steps,
|
||||
@@ -233,6 +241,11 @@ def metadata(report: dict) -> list[tuple]:
|
||||
("预期结果", report["expected"] or "未指定"),
|
||||
("执行状态", STATUS.get(report["status"], report["status"])),
|
||||
("验证结论", report["verdict"]),
|
||||
("判定依据", (report.get("test_result") or {}).get("reason") or "未记录"),
|
||||
(
|
||||
"验收证据",
|
||||
"\n".join((report.get("test_result") or {}).get("evidence") or []) or "未记录",
|
||||
),
|
||||
("开始时间", time_text(report["start"])),
|
||||
("结束时间", time_text(report["end"])),
|
||||
("设备", report["device"]),
|
||||
@@ -434,6 +447,11 @@ def word_report(report: dict, path: Path):
|
||||
if report["error"]:
|
||||
doc.add_heading("异常原因", 1)
|
||||
doc.add_paragraph(text(report["error"]))
|
||||
if result := report.get("test_result"):
|
||||
doc.add_heading("测试结论与依据", 1)
|
||||
doc.add_paragraph(text(result.get("reason") or "未记录"))
|
||||
for evidence in result.get("evidence") or []:
|
||||
doc.add_paragraph(text(evidence), style="List Bullet")
|
||||
doc.add_heading("任务信息", 1)
|
||||
details = [
|
||||
(label, value)
|
||||
@@ -441,10 +459,11 @@ def word_report(report: dict, path: Path):
|
||||
if label in {"任务编号", "用例编号", "检测项目", "测试子项", "开始时间", "结束时间", "设备"}
|
||||
]
|
||||
word_table(doc, details, (3.2, 13.3))
|
||||
doc.add_heading("任务目标", 2)
|
||||
doc.add_heading("任务目标与预期" if not report["expected"] else "任务目标", 2)
|
||||
doc.add_paragraph(report["goal"] or "未记录")
|
||||
doc.add_heading("预期结果", 2)
|
||||
doc.add_paragraph(report["expected"] or "未指定")
|
||||
if report["expected"]:
|
||||
doc.add_heading("预期结果", 2)
|
||||
doc.add_paragraph(report["expected"])
|
||||
if report.get("preconditions"):
|
||||
doc.add_paragraph("前置约束:" + text(report["preconditions"]))
|
||||
if report.get("task_config"):
|
||||
|
||||
Reference in new issue
Block a user