Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Minium 录制脚本转测试用例工具。自动解析录制脚本,生成符合规范的测试用例和页面对象,确保步骤完整、逻辑一致。
.claude/skills/minium-test-generator/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-14 | ✗→✓ | ▲ Improved | — | — |
| case-05 | ✗→✓ | ▲ Improved | — | — |
本技能用于将 Minium 录制脚本自动转换为符合项目规范的测试用例,确保步骤一个不漏,逻辑完全一致。
核心能力:
当用户提供录制文件时,禁止直接生成!
正确流程:
第 1 步:询问目录
→ "好的,我来帮你生成测试用例。请问测试用例目录在哪里?(完整路径)"
→ 等待用户回复
第 2 步:检查目录是否存在
→ 如果目录不存在 → 走【新建项目】流程
→ 如果目录已存在 → 走【添加到现有目录】流程
第 3 步:确认创建方式
→ 向用户展示将要创建/添加的文件列表
→ 等待用户确认
第 4 步:生成内容
→ 新建:创建完整项目结构
→ 添加:仅新增文件,不覆盖已有文件错误示范(禁止!):
当目录已存在时,禁止直接生成!
正确流程:
第 1 步:读取现有文件结构
→ 列出目录内容(pages/、test_cases/、*.py 等)
第 2 步:阅读已有代码
→ 阅读 pages/ 中的现有 Page Object
→ 分析命名规范、类命名、元素定位风格
→ 阅读 test_*.py 中的现有测试用例
→ 分析测试结构、断言风格、等待方式
第 3 步:总结现有规则
→ Page Object 命名规则(如:驼峰/下划线)
→ 元素定位规则(如:优先 selector 还是 xpath)
→ 测试用例结构(如:是否使用 mark_step_start)
→ 截图点命名规则(如:step_1、tap_1 等)
第 4 步:按现有规则生成新用例
→ 新 Page Object 遵循已有命名和结构
→ 新测试用例遵循已有风格和格式
→ 不引入与现有代码冲突的规范示例:
我:检测到目录已存在,我先阅读一下现有代码结构...
[阅读 pages/ 和 test_*.py 后]
我:现有代码规则如下:
- Page Object 命名:大驼峰(如 GroupHomepage)
- 元素定位:优先 selector,xpath 备用
- 测试结构:使用 mark_step_start 和 capture
- 截图点命名:动作 + 序号(如 tap_1、scroll_2)
我将按此规则生成新用例,确认吗?当 Page Object 文件已存在时:
❌ 错误做法:
- 创建新文件:pages/xxx_new.py
- 或创建重复文件:pages/xxx/xxx_v2.py
- 或创建分散的多个小方法
✅ 正确做法:
- 在原有文件末尾追加新方法
- 保持原有代码不变
- 同一个页面的操作整合到一个方法里
- 使用 basedef.py 中封装的方法(tap()、send_key())示例:
原文件:publish_start_group.py (已有 1000 行)
❌ 错误:创建多个分散小方法
def input_theme(self): ...
def click_help_entry(self): ...
def click_reward_switch(self): ...
✅ 正确:整合到一个完整方法
def pub_group_supply(self, theme_text="xxx"):
"""跟团供货模式发布完整流程"""
self.send_key(self.theme_input, theme_text)
self.tap(self.promise_btn)
self.scroll_to(400)
self.tap(self.help_entry)
...用例存放目录规则:
/pro/pages/homepage/group-homepage/... → 包含 homepage/pro/pages/home/leaders-management/... → 包含 home/pro/pages/seq-publish/... → 包含 seq-publishtestcase/ 下的子目录home → 找 testcase/home_page/ 或 testcase/home//pro/pages/seq-publish/... → 创建 testcase/seq_publish/核心原则:看项目的实际目录结构,不要硬编码映射关系!
Page Object 核心规则:
tap(), click(), click_element() 等send_key(), input_text(), type() 等scroll_to(), scroll() 等view.btn-know.button)click_xxx, input_xxx, select_xxxselfself.page.wait_for(x) 是录制工具自动生成的tap(), send_key())内部已有等待逻辑sleep() 或 wait_for().bat 运行脚本run.py).bat 文件示例:
python# 情况 1:用户已有封装方法(如 basedef.py 中有 tap() 和 send_key()) class SelectFollowReward(BaseDef): reward_value_input = "..." confirm_btn = "..." def input_reward_value(self, value): self.send_key(self.reward_value_input, str(value)) # 使用用户的封装 def click_confirm(self): self.tap(self.confirm_btn) # 使用用户的封装 # 情况 2:用户没有封装方法 class SelectFollowReward(BaseDef): reward_value_input = "..." confirm_btn = "..." def input_reward_value(self, value): self.page.get_element(self.reward_value_input).input(str(value)) def click_confirm(self): self.page.get_element(self.confirm_btn).tap()
新建项目结构:
tests/
├── pages/ # Page Object 层
│ ├── __init__.py # 导出所有页面对象
│ ├── [页面].py # 每个页面一个类
│ └── README.md # PO 模型说明
├── test_cases/ # 测试用例文档
│ └── [用例名].md # Markdown 格式用例
├── conftest.py # Pytest 配置
├── run_test.py # 测试启动脚本
└── test_[用例名].py # 可执行测试脚本当用户提供的目录不存在时:
我:好的,我来帮你生成测试用例。
检测到目录不存在,我将为你创建完整的测试项目结构:
📁 [用户提供的路径]/
├── pages/ # Page Object 层
│ ├── __init__.py
│ ├── [页面 1].py
│ └── [页面 2].py
├── test_cases/ # 测试用例文档
│ └── [用例名].md
├── conftest.py # Pytest 配置
├── run_test.py # 测试启动脚本
└── test_[用例名].py # 可执行测试脚本
确认开始创建吗?用户确认后:
当用户提供的目录已存在时:
我:好的,我来帮你生成测试用例。
检测到目录已存在,我将在现有目录下添加新用例:
📁 [用户提供的路径]/
├── pages/ # 新增 Page Object
│ └── [新页面].py
├── test_cases/ # 新增测试用例文档
│ └── [新用例名].md
└── test_[新用例名].py # 新增测试脚本
⚠️ 不会覆盖已有文件
确认开始创建吗?用户确认后:
使用 exec 检查目录是否存在:
bash# Windows PowerShell Test-Path "<用户提供的路径>" # 返回 True → 目录存在 → 走添加流程 # 返回 False → 目录不存在 → 走新建流程
检查子目录结构:
bash# 检查是否有 pages 目录 Test-Path "<路径>/pages" # 检查是否有 test_cases 目录 Test-Path "<路径>/test_cases" # 检查是否有 conftest.py Test-Path "<路径>/conftest.py"
根据检查结果判断:
pages/ 存在 → 追加新 Page Objectpages/ 不存在 → 创建 pages/ 目录test_cases/ 存在 → 追加新用例文档test_cases/ 不存在 → 创建 test_cases/ 目录你:帮我生成测试用例
[粘贴录制脚本]
我:好的,我来帮你生成测试用例。
首先,请告诉我:
1. 测试用例目录在哪里?(完整路径)
你:D:\projects\minium-tests\scenario-a
我:好的,我来检查目录...
检测到目录不存在,我将为你创建完整的测试项目结构:
📁 D:\projects\minium-tests\scenario-a\
├── pages/
│ ├── __init__.py
│ ├── homepage.py
│ └── detail_page.py
├── test_cases/
│ └── scenario_a.md
├── conftest.py
├── run_test.py
└── test_scenario_a.py
确认开始创建吗?
你:确认
我:✅ 项目结构已创建完成!
[输出所有文件内容]你:帮我生成测试用例
[粘贴录制脚本]
我:好的,我来帮你生成测试用例。
首先,请告诉我:
1. 测试用例目录在哪里?(完整路径)
你:C:\workspace\expression-trainer-miniprogram\tests
我:好的,我来检查目录...
检测到目录已存在,我将在现有目录下添加新用例:
📁 C:\workspace\expression-trainer-miniprogram\tests\
├── pages/ # 新增 Page Object
│ └── [新页面].py
├── test_cases/ # 新增测试用例文档
│ └── [新用例名].md
└── test_[新用例名].py # 新增测试脚本
⚠️ 不会覆盖已有文件
确认开始创建吗?
你:确认
我:✅ 测试用例已添加完成!
[输出新增文件内容]当你有以下需求时,直接说即可:
示例:
你:我给你一个录制文件,帮我生成测试用例
[从你的录制脚本目录找到 Python 文件,复制内容粘贴]
我:好的,我来帮你生成测试用例。
首先,请告诉我:
1. 测试用例目录在哪里?(完整路径)
2. 是否有现有的测试项目结构?核心触发场景: 用户提供 Minium 录制脚本,要求生成或验证测试用例
触发词:
文件路径示例:
<你的录制脚本目录>\[场景名称]\[时间戳]\xxx.py响应流程:
你:我给你一个录制文件,帮我生成测试用例
[粘贴录制脚本内容]
我:好的,我来帮你生成测试用例。
首先,请告诉我:
1. 测试用例目录在哪里?(完整路径)
2. 是否有现有的测试项目结构?触发词:
响应流程:
你:帮我生成测试用例
[粘贴录制脚本内容]
我:好的,我来帮你生成测试用例。
首先,请告诉我:
1. 测试用例目录在哪里?(完整路径)
2. 是否有现有的测试项目结构?触发词:
示例:
你:帮我验证一下这个测试用例有没有漏掉步骤
录制脚本:<你的录制脚本目录>\xxx.py
测试用例:<你的项目目录>\testcase\xxx\test_xxx.py
我:好的,我来对比验证...触发词:
示例:
你:帮我解析这个录制脚本,看看有多少步
[从你的录制脚本目录找到 Python 文件,复制内容粘贴]
我:好的,我来运行 parse_steps.py 解析...功能: 解析录制脚本,生成步骤清单
用法:
bashpython <技能包路径>/scripts/parse_steps.py \ --input <录制脚本路径> \ --output <输出路径>
示例:
bashpython scripts/parse_steps.py \ --input recorded_script.py \ --output steps_checklist.md
功能: 生成页面对象和测试用例
用法:
bashpython <技能包路径>/scripts/generate_pages.py \ --input <录制脚本路径> \ --output <测试用例输出目录> \ --pages <页面类目录>
示例:
bashpython scripts/generate_pages.py \ --input recorded_script.py \ --output testcase/xxx/ \ --pages pages/pages/
功能: 验证测试用例是否漏掉步骤
用法:
bashpython <技能包路径>/scripts/validate_steps.py \ --input <录制脚本路径> \ --test <测试用例路径> \ --report <验证报告路径>
检查项:
bash# 1. 运行解析脚本 python scripts/parse_steps.py \ --input recorded_script.py \ --output steps_checklist.md # 2. 查看生成的步骤清单 cat steps_checklist.md
输出:
bash# 运行生成脚本 python scripts/generate_pages.py \ --input recorded_script.py \ --output testcase/xxx/ \ --pages pages/pages/
输出:
bash# 运行验证工具 python scripts/validate_steps.py \ --input recorded_script.py \ --test testcase/xxx/test_xxx.py \ --report validation_report.md
输出:
wait_for_page_success()在生成测试用例后,必须检查:
validate_steps.py 验证?| 文档 | 说明 | |------|------| | core-skills/避免漏掉步骤.md | 核心技能:如何避免漏掉步骤 | | docs/代码生成质量控制流程.md | 完整的质量控制流程 | | docs/代码审查清单.md | 提交前必须逐项检查 | | docs/代码规范.md | 代码规范详细说明 |
你:
我给你一个录制文件,帮我生成测试用例
[从你的录制脚本目录找到 Python 文件,复制内容粘贴]我:
好的,我来使用 minium-test-generator 技能为你生成测试用例。
第 1 步:解析录制脚本...
python scripts/parse_steps.py --input recorded_script.py --output steps_checklist.md
第 2 步:生成测试用例...
python scripts/generate_pages.py --input recorded_script.py --output testcase/xxx/ --pages pages/pages/
第 3 步:验证步骤完整性...
python scripts/validate_steps.py --input recorded_script.py --test testcase/xxx/test_xxx.py --report validation_report.md
✅ 生成完成!测试用例已保存到 testcase/xxx/test_xxx.py
验证报告:validation_report.md你:
帮我验证一下这个测试用例有没有漏掉步骤
录制脚本:<你的录制脚本目录>\recorded_script.py
测试用例:<你的项目目录>\testcase\xxx\test_xxx.py我:
好的,我来运行 validate_steps.py 验证...
python scripts/validate_steps.py \
--input <你的录制脚本目录>\recorded_script.py \
--test <你的项目目录>\testcase\xxx\test_xxx.py \
--report validation_report.md
验证结果:
✅ 所有步骤都已转换(X 步,一个不漏)
✅ 相邻步骤元素检查通过
✅ 特殊逻辑检查通过
✅ 页面跳转等待检查通过| 指标 | 数值 | |------|------| | 支持的文件格式 | Minium 录制脚本 (.py) | | 生成的文件格式 | Python 测试用例 (.py) | | 验证检查项 | 4 项 | | 支持的特殊逻辑 | 三层判断、else 判断、循环、页面跳转 | | 典型录制脚本路径 | <你的录制脚本目录>\[场景名称]\[时间戳]\ |
bash# 1. 查看技能文档 cat <技能包路径>/README.md # 2. 学习核心技能 cat <技能包路径>/core-skills/避免漏掉步骤.md # 3. 使用工具 python <技能包路径>/scripts/parse_steps.py --help
_最后更新:2026-03-23_
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +61 percentage points is the difference between those two pass rates over the 23 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.