Testcase Generator

v1.0.0

用来生成用例的技能,针对已有的用例库和提供的prd进行分析交互,最终输出生成的用例,会区分新增和更新,生成2个excel文件.

0· 92·0 current·0 all-time
byMelissa@melissa-lu
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (generate and update test cases, produce 2 Excel files) matches the included Python scripts (case_generator.py and version_manager.py). The code implements Excel generation and library version/update operations which are coherent with the stated purpose. Minor mismatch: SKILL.md promises PRD parsing (PDF/Word/Markdown) and OCR support, but there is no code in the repository that performs document parsing or OCR — those steps appear to be left to the agent/human or not implemented in these scripts.
Instruction Scope
Runtime instructions operate on local files and directories (e.g., ~/.openclaw/workspace/, ~/.openclaw/products/, product-specific Excel files). That is consistent with the purpose. The SKILL.md explicitly instructs reading user-provided update files and storing outputs in the user's home workspace. Nothing in the instructions directs data to external network endpoints. However the skill reads and writes arbitrary Excel files (including the configured 'case library' target paths) — the update path will overwrite target Excel files on disk, so the agent or user must ensure correct file paths and backups.
Install Mechanism
No install spec and no external downloads; this is an instruction+script-only skill. It relies on standard Python libraries (openpyxl) but does not declare an installer — minimal install risk. No network fetches or third‑party package installation are present in the manifest.
Credentials
The skill requests no environment variables, no credentials, and no special config paths beyond user-local paths under ~/.openclaw and configured Excel paths. The requested file access is proportional to the stated behavior (reading/writing local case libraries and workspace files).
!
Persistence & Privilege
The skill is not always-on and does not request credentials, but it does modify files on the host: version_manager.update_library will write back to configured case library Excel files (overwriting them), and the scripts create metadata and output files under ~/.openclaw/workspace/. That file-write capability is consistent with the purpose but is potentially destructive if misconfigured — users should confirm target paths, back up libraries, and review the code before running automated updates.
Assessment
This skill is internally consistent with its goal of generating and updating test-case Excel files and does not contact external endpoints or request secrets. Before using it: 1) Inspect and, if necessary, edit product config paths in ~/.openclaw/products/ (or the built-in DEFAULT_CONFIG) so the scripts target the correct files. 2) Back up any existing case library Excel files — update_library will overwrite target files. 3) Note that PRD parsing/OCR functionality mentioned in SKILL.md is not implemented in the included scripts; you'll need to provide parsed content or add parsing code/tools. 4) Run the scripts on sample/test directories first to validate behavior and outputs. 5) If you plan to integrate this into an automated agent workflow, ensure interactive confirmation steps are preserved (the CLI update operation is non-interactive) or wrap the calls to require explicit user approval.

Like a lobster shell, security has layers — review code before you run it.

latestvk974ayjjqh1rm47kdx6n8t7e1h84h3rm
92downloads
0stars
1versions
Updated 1w ago
v1.0.0
MIT-0

测试用例生成器 (testcase-generator)

根据产品需求文档(PRD)生成和更新测试用例,遵循产品测试用例库风格规范。

触发场景

  • "根据PRD生成测试用例"
  • "更新测试用例"
  • "分析这个需求的测试点"
  • "帮我写测试用例"
  • "这个PRD需要哪些用例"

多产品架构

本 Skill 支持多个产品(UHost、UPHost、私有专区等),每个产品有独立配置。

产品列表

产品用例库说明
uhost主机(306) + GPU(69) + 镜像(56)431 条总计
uphost(待配置)
privatezone(待配置)

切换产品

使用 --product 参数指定产品:

version_manager.py --product uhost
case_generator.py --product uhost

核心能力

  1. PRD解析 - 读取和理解产品需求文档
  2. 测试点分析 - 自动梳理功能点、边界条件、异常场景
  3. 用例库对比 - 查找可复用的现有用例,避免重复
  4. 用例生成 - 按照产品标准格式生成新增用例
  5. 用例更新 - 生成更新说明,标注修改位置和原因
  6. 版本管理 - 支持用例库版本检查和增量更新

工作流程

🔍 阶段0: 用例库版本检查(必须)

每次执行前,必须先检查用例库是否为最新版本。

步骤:

  1. 读取产品配置

    python3 scripts/version_manager.py --product uhost
    
  2. 显示版本信息,询问用户确认

    📚 当前 [产品名] 用例库版本:
    - CPU用例库: 306 条 (最后更新: YYYY-MM-DD)
    - GPU用例库: 69 条 (最后更新: YYYY-MM-DD)
    - 镜像用例库: 56 条 (最后更新: YYYY-MM-DD)
    - 总计: 431 条
    
    ❓ 这是最新版本吗?
    - 如果是,输入 "是" 继续
    - 如果不是,请提供更新的用例文件
    
  3. 如果用户提供更新文件

    • 读取更新文件(支持增量更新)
    • 按 UUID 覆盖现有用例
    • 更新用例库元数据
    • 重新统计用例数量
  4. 确认后继续流程


📖 阶段1: PRD解析

目标: 理解需求,提取核心功能点和变更详情

步骤:

  1. 读取PRD文件

    • 支持格式: PDF, Word, Markdown, 纯文本
    • 如果是图片,使用 OCR 提取文字
  2. 提取关键信息

    • 需求背景
    • 功能变更点
    • 涉及的模块/页面
    • 涉及的接口
    • 计费相关变更
    • 特殊规则
  3. 生成 PRD 摘要

    • 保存到 ~/.openclaw/workspace/memory/{需求名称}_PRD摘要.md
    • 包含:标题、版本、核心变更、涉及范围

🎯 阶段2: 测试点分析

目标: 根据PRD梳理详细的测试场景和验证点

步骤:

  1. 按模块分类测试点

    • 前端交互测试
    • 功能流程测试
    • 接口测试
    • 计费测试
    • 存量数据处理
    • 异常场景
  2. 识别测试类型

    • 创建/查询/更新/删除 (CRUD)
    • 边界值测试
    • 权限验证
    • 性能测试
    • 兼容性测试
  3. 梳理测试点清单

    • 每个功能点对应的测试场景
    • 前置条件
    • 验证点
    • 优先级(P0/P1/P2/P3)
  4. 生成测试点分析文档

    • 保存到 ~/.openclaw/workspace/memory/{需求名称}_测试点分析.md
    • 包含:测试场景矩阵、待确认问题清单
  5. 人机交互确认 ⚠️

    📋 测试点分析完成,共梳理 XX 个测试场景
    
    ❓ 是否有遗漏的场景?是否有不清楚的地方需要确认?
    

📚 阶段3: 用例库对比

目标: 查找可复用的现有用例,判断需要新增还是更新

步骤:

  1. 读取产品用例库(根据 config.yaml 中的路径)

    • CPU 用例库
    • GPU 用例库(如适用)
    • 镜像用例库(如适用)
  2. 按关键词搜索相关用例

    • 搜索范围:用例名称、所属模块、步骤描述
    • 关键词:需求涉及的功能、模块、操作
  3. 分析匹配结果

    • 完全匹配: 可直接更新现有用例
    • 部分匹配: 需要增加步骤或验证点
    • 无匹配: 需要新增用例
  4. 生成对比分析报告

    • 保存到 ~/.openclaw/workspace/memory/{需求名称}_用例对比分析.md
    • 包含:
      • 可复用的现有用例列表
      • 需要更新的用例及更新点
      • 需要新增的用例清单
  5. 人机交互确认 ⚠️

    📊 用例对比完成
    
    - 可复用/更新: XX 条
    - 需要新增: XX 条
    
    ❓ 确认对比结果?是否有需要调整的地方?
    

✍️ 阶段4: 生成用例文件

目标: 按照产品标准格式生成新增用例和更新说明

步骤:

4.1 生成新增用例
  1. 创建 Excel 文件

    • 文件名: {output_dir}/{需求名称}_新增用例.xlsx
  2. 表头(12列)

    用例ID | 用例名称 | 所属模块 | 标签 | 前置条件 | 备注 | 步骤描述 | 预期结果 | 用例等级 | 用例类型 | 是否支持自动化 | 是否支持拨测
    
  3. 填写规则

    • 用例ID: 留空 ⚠️
    • 所属模块: 在生成的模块路径前加 /ai 前缀 ⚠️
      • 例: /ai/镜像常规/镜像常规/功能/自制镜像tab下/导入镜像
    • 步骤描述: 使用【数字】标记,如 【1】【2】【3】
    • 预期结果: 使用【数字】标记,与步骤一一对应
    • 前置条件: 使用数字编号,如 1. 2. 3.
    • 用例等级: P0/P1/P2/P3(根据重要性)
    • 用例类型: 1=功能,2=界面,3=接口
    • 是否支持自动化: 1=是,2=否
    • 是否支持拨测: 1=是,2=否
4.2 生成更新用例
  1. 创建 Excel 文件

    • 文件名: {output_dir}/{需求名称}_更新用例.xlsx
  2. 表头(17列)

    用例ID | 用例名称 | 所属模块 | 标签 | 前置条件 | 备注 | 步骤描述 | 预期结果 | 用例等级 | 用例类型 | 是否支持自动化 | 是否支持拨测 | 更新类型 | 更新位置 | 原内容 | 更新后内容 | 更新原因
    
  3. 填写规则

    • 前12列:保留原用例的完整信息
    • 更新类型: 如"增加步骤"、"更新预期结果"、"修改前置条件"
    • 更新位置: 如"步骤【N】后"、"预期结果【N】"
    • 原内容: 现有用例的相关内容片段
    • 更新后内容: 更新后的完整内容
    • 更新原因: 为什么要更新,关联的需求点
  4. 颜色标注

    • 不同用例库来源用不同颜色底色区分
    • 方便人工审核

产品配置说明

每个产品的配置存储在 ~/.openclaw/products/{product}/config.yaml

配置结构

product: uhost
display_name: "UHost 主机"

case_libraries:
  cpu:
    path: /path/to/UHost-cpu.xlsx
    name: "CPU用例库"
    count: 306
  
  gpu:
    path: /path/to/UHost-gpu.xlsx
    name: "GPU用例库"
    count: 69
  
  image:
    path: /path/to/UHost-image.xlsx
    name: "镜像用例库"
    count: 56

total_cases: 431
last_updated: "2026-04-09"

新增产品

  1. 创建目录: ~/.openclaw/products/{product}/
  2. 添加 config.yaml
  3. 复制风格规范: references/
  4. 可选: 添加 templates/

格式规范

步骤描述规范

【1】第一步操作描述
【2】第二步操作描述
【3】第三步操作描述
...
【N】第N步操作描述
  • 使用中文全角方括号【】
  • 每个步骤独立一行,用 \n 分隔
  • 步骤描述要具体,包含操作对象、操作动作、参数值
  • 平均步骤数: 10.4 步

预期结果规范

【1】第一步预期结果
【2】第二步预期结果
【3】第三步预期结果
...
【N】第N步预期结果
  • 步骤编号与步骤描述一一对应
  • 描述要明确,可验证
  • 如果一个步骤有多个验证点,使用子编号:
    【4】1. 验证点1
    2. 验证点2
    3. 验证点3
    

前置条件规范

1.前置条件1
2.前置条件2
3.前置条件3
  • 使用数字编号 + 点号
  • 每个条件独立一行,用 \n 分隔
  • 88.2%的用例使用数字编号

模块路径规范

/一级模块/二级模块/三级模块/.../N级模块
  • / 开头和分隔
  • 主流层级:3-5层(96.9%)
  • 新增用例: 在路径前加 /ai 前缀

用例名称规范

功能模块-具体操作-场景说明
  • 使用连字符 - 分隔(81.4%的用例)
  • 简洁明了,包含核心操作动词
  • 例: 创建主机-登录设置主机操作-重装系统-登录及其他

用例等级规范

  • P0 (6.9%): 冒烟/核心流程/阻塞性
  • P1 (21.6%): 主要功能/高频场景
  • P2 (49.0%): 标准功能/常规场景 ⭐ (最常见)
  • P3 (22.5%): 边缘场景/辅助功能

用例类型规范

  • 类型1 (85.6%): 功能测试 ⭐⭐⭐
  • 类型2 (1.3%): 界面/UI测试
  • 类型3 (13.1%): 接口测试

输出目录

  • 默认: ~/.openclaw/workspace/
  • 文件命名格式:
    • {需求名称}_新增用例.xlsx
    • {需求名称}_更新用例.xlsx
    • {需求名称}_测试点分析.md
    • {需求名称}_用例对比分析.md

版本历史

  • v1.0 (2026-04-08): 初始版本,基于 Windows镜像收费 需求实践总结
  • v1.1 (2026-04-09): 改造为多产品架构,支持配置化

维护人: 球球 🦊

Comments

Loading comments...