report
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSmart Test Reporting
智能测试报告
Generate test reports that plug into the user's existing workflow. Zero new tools.
生成可融入用户现有工作流的测试报告,无需新增任何工具。
Steps
步骤
1. Run Tests (If Not Already Run)
1. 运行测试(若尚未运行)
Check if recent test results exist:
bash
ls -la test-results/ playwright-report/ 2>/dev/nullIf no recent results, run tests:
bash
npx playwright test --reporter=json,html,list 2>&1 | tee test-output.log检查是否存在近期测试结果:
bash
ls -la test-results/ playwright-report/ 2>/dev/null若不存在近期结果,则运行测试:
bash
npx playwright test --reporter=json,html,list 2>&1 | tee test-output.log2. Parse Results
2. 解析结果
Read the JSON report:
bash
npx playwright test --reporter=json 2> /dev/nullExtract:
- Total tests, passed, failed, skipped, flaky
- Duration per test and total
- Failed test names with error messages
- Flaky tests (passed on retry)
读取JSON报告:
bash
npx playwright test --reporter=json 2> /dev/null提取以下信息:
- 测试总数、通过数、失败数、跳过数、不稳定数
- 单测试耗时与总耗时
- 失败测试名称及错误信息
- 不稳定测试(重试后通过的测试)
3. Detect Report Destination
3. 检测报告目标位置
Check what's configured and route automatically:
| Check | If found | Action |
|---|---|---|
| TestRail configured | Push results via |
| Slack configured | Post summary to Slack |
| GitHub Actions | Results go to PR comment via artifacts |
| HTML reporter | Open or serve the report |
| None of the above | Default | Generate markdown report |
检查已配置项并自动路由:
| 检查项 | 如果已配置 | 操作 |
|---|---|---|
| 已配置TestRail | 通过 |
| 已配置Slack | 向Slack发送结果汇总 |
| 已配置GitHub Actions | 通过工件将结果发送至PR评论 |
| 已生成HTML报告 | 打开或托管该报告 |
| 以上均不满足 | 默认情况 | 生成Markdown报告 |
4. Generate Report
4. 生成报告
Markdown Report (Always Generated)
Markdown报告(始终生成)
markdown
undefinedmarkdown
undefinedTest Results — {{date}}
测试结果 — {{date}}
Summary
汇总
- ✅ Passed: {{passed}}
- ❌ Failed: {{failed}}
- ⏭️ Skipped: {{skipped}}
- 🔄 Flaky: {{flaky}}
- ⏱️ Duration: {{duration}}
- ✅ 通过:{{passed}}
- ❌ 失败:{{failed}}
- ⏭️ 跳过:{{skipped}}
- 🔄 不稳定:{{flaky}}
- ⏱️ 总耗时:{{duration}}
Failed Tests
失败测试详情
| Test | Error | File |
|---|---|---|
| {{name}} | {{error}} | {{file}}:{{line}} |
| 测试用例 | 错误信息 | 文件位置 |
|---|---|---|
| {{name}} | {{error}} | {{file}}:{{line}} |
Flaky Tests
不稳定测试
| Test | Retries | File |
|---|---|---|
| {{name}} | {{retries}} | {{file}} |
| 测试用例 | 重试次数 | 文件位置 |
|---|---|---|
| {{name}} | {{retries}} | {{file}} |
By Project
按项目统计
| Browser | Passed | Failed | Duration |
|---|---|---|---|
| Chromium | X | Y | Zs |
| Firefox | X | Y | Zs |
| WebKit | X | Y | Zs |
Save to `test-reports/{{date}}-report.md`.| 浏览器 | 通过数 | 失败数 | 耗时 |
|---|---|---|---|
| Chromium | X | Y | Z秒 |
| Firefox | X | Y | Z秒 |
| WebKit | X | Y | Z秒 |
保存至 `test-reports/{{date}}-report.md`。Slack Summary (If Webhook Configured)
Slack汇总(若已配置Webhook)
bash
curl -X POST "$SLACK_WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d '{
"text": "🧪 Test Results: ✅ {{passed}} | ❌ {{failed}} | ⏱️ {{duration}}\n{{failed_details}}"
}'bash
curl -X POST "$SLACK_WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d '{
"text": "🧪 测试结果:✅ {{passed}} | ❌ {{failed}} | ⏱️ {{duration}}\n{{failed_details}}"
}'TestRail Push (If Configured)
推送至TestRail(若已配置)
Invoke with the JSON results.
/pw:testrail push调用 并传入JSON格式的测试结果。
/pw:testrail pushHTML Report
HTML报告
bash
npx playwright show-reportOr if in CI:
bash
echo "HTML report available at: playwright-report/index.html"bash
npx playwright show-report若在CI环境中:
bash
echo "HTML报告地址:playwright-report/index.html"5. Trend Analysis (If Historical Data Exists)
5. 趋势分析(若存在历史数据)
If previous reports exist in :
test-reports/- Compare pass rate over time
- Identify tests that became flaky recently
- Highlight new failures vs. recurring failures
若 目录下存在过往报告:
test-reports/- 对比不同时间段的通过率
- 识别近期变为不稳定的测试用例
- 突出新出现的失败与重复出现的失败
Output
输出内容
- Summary with pass/fail/skip/flaky counts
- Failed test details with error messages
- Report destination confirmation
- Trend comparison (if historical data available)
- Next action recommendation (fix failures or celebrate green)
- 包含通过/失败/跳过/不稳定数量的汇总信息
- 带有错误信息的失败测试详情
- 报告目标位置确认
- 趋势对比(若有历史数据)
- 下一步操作建议(修复失败测试或庆祝全通过)