AIGC测试报告:用例执行详情逻辑优化

AIGC测试报告:用例执行详情逻辑优化

一、问题描述

现场问题:

  • 用户可能只建立'中试第3轮冒烟'测试单,不会再去建立中试第3轮测试单
  • 数据库没有第3轮正式测试任务,导致 test_case_execution 缺少第3轮

二、方案概述

通过 all_test_schedule 检测是否存在冒烟测试但无对应正式测试轮次,补充"缺陷回归"行。


三、修改点

修改点1:main_report_generator.py(约第763-786行)

# 原逻辑:直接遍历 test_cases 构建表格
test_case_execution = []
for round_key, case_info in test_cases.items():
    test_case_execution.append({...})

# 优化后:
# 1. 先添加正常的用例执行数据
test_case_execution = []
for round_key, case_info in test_cases.items():
    test_case_execution.append({...})

# 2. 检查 all_test_schedule 中是否有冒烟测试但无对应正式测试
existing_rounds = {item["轮次"] for item in test_case_execution}

all_schedule = self.config.get("all_test_schedule", [])
for schedule_item in all_schedule:
    round_name = schedule_item.get("round_name", "")
    if "冒烟" in round_name or "smoke" in round_name.lower():
        # 提取轮次编号
        match = re.search(r'第(\d+)轮', round_name.replace('l', '1').replace('I', '1'))
        if match:
            round_num = int(match.group(1))
            round_key = f"第{round_num}轮"
            if round_key not in existing_rounds:
                test_case_execution.append({
                    "轮次": round_key,
                    "用例个数": "",
                    "执行数": "",
                    "通过数": "",
                    "未通过数": "",
                    "通过比例": "",
                    "备注": "缺陷回归"
                })
                existing_rounds.add(round_key)

# 3. 按轮次排序
test_case_execution.sort(key=lambda x: int(re.sub(r'\D', '', x["轮次"])))

四、支持的命名格式

任务名称 识别结果
中试第1轮 第1轮
第1轮 第1轮
1轮 第1轮
第l轮 / 第I轮 第1轮
第1轮冒烟 冒烟测试 → 缺陷回归
中试第1轮冒烟 冒烟测试 → 缺陷回归
1轮冒烟 冒烟测试 → 缺陷回归

五、预期效果

轮次 用例个数 执行数 通过数 未通过数 通过比例 备注
第1轮 59 59 39 20 66.1%
第2轮 59 59 59 0 100.0%
第3轮 缺陷回归
posted @ 2026-03-17 17:47  菠萝包与冰美式  阅读(6)  评论(0)    收藏  举报