Agent SkillsDanielSuo117/velocitai › test-runner

test-runner

GitHub

用于运行pytest测试并分析结果。支持单故事调试和全量回归,强制确认环境参数。根据失败特征(定位符、超时、断言、认证)分类诊断,提供Allure报告查看及结构化摘要输出。

zh/skills/test-runner/SKILL.md DanielSuo117/velocitai

Trigger Scenarios

运行测试 跑测试 run test pytest 失败分析 allure

Install

npx skills add DanielSuo117/velocitai --skill test-runner -g -y
More Options

Non-standard path

npx skills add https://github.com/DanielSuo117/velocitai/tree/main/zh/skills/test-runner -g -y

Use without installing

npx skills use DanielSuo117/velocitai@test-runner

指定 Agent (Claude Code)

npx skills add DanielSuo117/velocitai --skill test-runner -a claude-code -g -y

安装 repo 全部 skill

npx skills add DanielSuo117/velocitai --all -g -y

预览 repo 内 skill

npx skills add DanielSuo117/velocitai --list

SKILL.md

Frontmatter
{
    "name": "test-runner",
    "description": "运行 pytest + 结构化分析失败原因。触发:运行测试、跑测试、run test、pytest、失败分析、allure。"
}

Test Runner — 运行测试与结果分析

⚠️ 运行前必须向用户确认 --env(见 agent-behavior.md P0.2)。 即使 config/settings.py::DEFAULT_ENV="prod"、即使下方示例写 --env=<pre|prod>(示例 ≠ 默认值),仍必须问用户。

运行前准备

# 确认虚拟环境已激活
source .venv/bin/activate

# 确认依赖已安装
pip list | grep -E "playwright|pytest|allure"

运行模式

所有测试均基于真实环境(URL + token)运行。

模式 1: 单个 story(调试 / 定位符验证)

场景: 替换定位符后验证、调试单个页面回归点

# 对应角色
pytest tests/<role>/test_<role>_flow.py --env=<pre|prod> -v -k "test_xxx"
# 对应角色
pytest tests/<role>/test_<role>_home.py --env=<pre|prod> -v -k "test_<case_name>"

模式 2: 按角色 / 全量回归

场景: 发版前验证、完整回归

# <角色A>全量
pytest tests/<roleA>/ --env=<pre|prod>
# <角色B>全量
pytest tests/<roleB>/ --env=<pre|prod>
# 全量
pytest tests/ --env=<pre|prod>

查看 Allure 报告

# 启动报告服务器查看(运行完测试后直接可用)
allure serve reports/allure-results

# 生成静态报告(可部署)
allure generate reports/allure-results -o reports/allure-report --clean

结果分析

pytest 输出解读

tests/test_xxx.py::TestXxx::test_method PASSED    → 通过
tests/test_xxx.py::TestXxx::test_method FAILED    → 失败(需分析)
tests/test_xxx.py::TestXxx::test_method ERROR     → fixture/setup 异常
tests/test_xxx.py::TestXxx::test_method SKIPPED   → 跳过

失败分类与处理

运行失败后,按以下分类诊断:

类型 A: 定位符失效

特征:

TimeoutError: Timeout 10000ms exceeded.
  waiting for locator("text=<功能名>")

处理: 触发 locator-replacer skill,使用 agent-browser 访问真实页面重新抽取定位符(工具选型遵循 agent-behavior P0.4)。

类型 B: 页面加载超时

特征:

TimeoutError: page.wait_for_load_state: Timeout 30000ms exceeded.
  waiting for "networkidle"

处理:

  1. 检查网络连通性(hosts 配置、VPN)
  2. 检查 token 是否过期
  3. 增大 DEFAULT_TIMEOUT(临时措施)

类型 C: 断言失败

特征:

AssertionError: <页面中文名>加载失败
assert False

处理:

  1. 页面是否正确导航到目标 URL
  2. PAGE_IDENTIFIER 定位符是否仍然有效
  3. 页面内容是否因版本更新发生变化

类型 D: 认证失败

特征:

AssertionError: Token 登录失败

处理:

  1. 检查 config/settings.py 中的 token 是否有效
  2. 检查 --env 参数是否选对
  3. 检查本地 hosts 是否指向正确的服务器 IP

💡 快速排查建议

当失败需要深入排查时(定位符失效、页面结构变化等),建议进入 quick-debug 模式:通过 token 免登直接跳转到问题页面,避免从登录重走完整流程。


结果摘要模板

运行完成后,按以下格式输出摘要:

## 测试运行摘要

**运行模式:** 单个 story / 主流程全量
**环境:** pre / prod
**时间:** 2026-04-15 15:30

### 结果

| 状态 | 数量 |
|------|------|
| PASSED | X |
| FAILED | X |
| ERROR | X |
| SKIPPED | X |

### 失败详情(如有)

| 测试用例 | 失败类型 | 原因 | 建议操作 |
|----------|---------|------|---------|
| test_xxx | A: 定位符失效 | text=xxx 不唯一 | 使用 locator-replacer |
| test_yyy | D: 认证失败 | token 过期 | 更新 settings.py |

Version History

  • 6d28887 Current 2026-07-05 20:21

Same Skill Collection

skills/add-regression-point/SKILL.md
skills/architecture/SKILL.md
skills/browser-config/SKILL.md
skills/case-round-trip/SKILL.md
skills/gen-page-test/SKILL.md
skills/locator-replacer/SKILL.md
skills/page-load-assertion/SKILL.md
skills/quick-debug/SKILL.md
skills/save-verify-strategy/SKILL.md
skills/test-runner/SKILL.md
zh/skills/add-regression-point/SKILL.md
zh/skills/architecture/SKILL.md
zh/skills/browser-config/SKILL.md
zh/skills/case-round-trip/SKILL.md
zh/skills/gen-page-test/SKILL.md
zh/skills/locator-replacer/SKILL.md
zh/skills/page-load-assertion/SKILL.md
zh/skills/quick-debug/SKILL.md
zh/skills/save-verify-strategy/SKILL.md
en/skills/SKILL.md
skills/code-review-graph/SKILL.md
skills/SKILL.md
skills/wait-strategy/SKILL.md
zh/skills/code-review-graph/SKILL.md
zh/skills/SKILL.md
zh/skills/wait-strategy/SKILL.md

Metadata

Files
0
Version
6d28887
Hash
77f07ed6
Indexed
2026-07-05 20:21

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-08 22:24
浙ICP备14020137号-1 $Гость$