---
name: generate-test-report
description: Use when TESTER needs to generate the final test summary report at Gate 4 after all test execution is complete. Aggregates results from evidence/ and bugs/ directories, verifies acceptance criteria coverage, and produces a Go/No-Go recommendation.
keywords: test report, summary, sign-off, go no-go, gate 4, evidence, bug summary, coverage
---

# Generate Test Report — Gate 4

> **Phạm vi:** Gate 4 — Báo cáo & Sign-off trong workflow 4-gate (`docs/workflow.md`)
> **Chỉ chạy sau khi Gate 3 đã được TESTER gõ `APPROVED`.**

---

## Điều kiện vào Gate 4

- ✅ Gate 3 APPROVED — tất cả critical/high bugs đã resolved và re-tested
- ✅ Đã có đầy đủ: `evidence/`, `bugs/`, `test-plan/test-cases/`, `test-plan/checklist.md`
- ✅ `test-plan/impact-analysis.md` tồn tại (kể cả khi không có PR — file ghi "chưa có dev artifacts")

---

## Quy trình tạo Test Report

### Bước 1 — Thu thập kết quả

Đọc toàn bộ:
- `evidence/*/result.md` → đếm Pass / Fail / Blocked per TC
- `bugs/BUG-*.md` → đếm bugs theo severity, trạng thái resolved/unresolved
- `test-plan/test-cases/*.md` → danh sách TC ID và module

Tổng hợp per module theo format template (R1/R2 tracking từ testcase files).

### Bước 2 — Kiểm tra coverage

- So sánh TC đã thực thi với checklist `test-plan/checklist.md`
- Verify acceptance criteria từ `test-plan/test-analysis.md` (Gate 1) — từng item đã cover chưa?
- Tính % hoàn thành: `(Tổng passed / Total test cases) × 100`
- **Verify regression scope từ `test-plan/impact-analysis.md`**: đọc "Đề xuất Regression TCs" — những regression TCs đó đã được execute chưa? Nếu chưa → flag trong report (không block Go/No-Go nhưng phải ghi nhận rõ).

### Bước 3 — Đánh giá Exit Criteria & Go/No-Go

| Điều kiện | Go | No-Go |
|---|---|---|
| Critical bugs | 0 unresolved | Còn ≥ 1 |
| High bugs | 0 unresolved hoặc có deferred plan | Còn unresolved không có plan |
| Coverage | ≥ 100% acceptance criteria covered | Còn AC chưa test |
| Pass rate | Đạt ngưỡng exit criteria | Dưới ngưỡng |

**Conditional Go:** Pass nhưng còn Medium/Low bugs chưa fix — ghi rõ điều kiện deferred.

### Bước 4 — Viết Test Report

**Dùng template:** `templates/test-report.md`

Điền đầy đủ:
- **Project Information:** lấy từ ticket context
- **Test Execution Summary:** per module, R1/R2 stats, % hoàn thành
- **Bug Summary:** tổng hợp từ `bugs/`
- **Coverage:** acceptance criteria đã cover
- **Sign-off Decision:** Go / No-Go / Conditional Go + lý do cụ thể

Output: `test-plan/test-report.md`

Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).

---

## Gate 4 Display

```
⏸️ GATE 4: TEST REPORT READY

Overall: [Pass / Fail / Conditional]
Passed: [N/total] | Bugs unresolved: [N Critical / N High / N Medium / N Low]
Coverage: [N]% acceptance criteria covered

Recommendation: [Go / No-Go / Conditional go]
[Nếu Conditional: điều kiện cụ thể]

→ Review: [test-plan/test-report.md](test-plan/test-report.md)
→ Type APPROVED to sign off and submit to Backlog/Jira
→ Type NO-GO: [reason] to reject release
```

---

## Xử lý phản hồi của TESTER

**`APPROVED`** → Done. Hướng dẫn TESTER copy nội dung lên Backlog/Jira ticket.

**`NO-GO: [reason]`** → Ghi nhận lý do vào test-report.md. List những gì cần fix trước khi release.

---

## Mandatory Rules

- ❌ KHÔNG generate report khi còn critical bug chưa resolved
- ❌ KHÔNG tự quyết Go/No-Go thay TESTER — chỉ đưa ra recommendation
- ✅ PHẢI verify từng acceptance criteria từ Gate 1 trước khi kết luận coverage
- ✅ PHẢI trích dẫn TC ID cụ thể khi claim "requirement X đã covered"
- ✅ Bugs deferred PHẢI có justification rõ ràng trong report
