.gemini/skills/testing-guide/SKILL.md
[UDS] 測試金字塔與 UT/IT/ST/E2E 測試撰寫標準
npx skillsauth add asiaostrich/universal-dev-standards testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
語言: English | 繁體中文
版本: 1.1.0 最後更新: 2025-12-29 適用範圍: Claude Code Skills
本 Skill 提供測試金字塔標準和系統化測試的最佳實踐,支援 ISTQB 和業界通行金字塔框架。
UDS 提供 6 個測試相關技能,使用以下決策樹找到適合的:
你想做什麼?
├── 測量程式碼覆蓋率(行/分支/函數) → /coverage
├── 追蹤需求是否有對應測試(AC 可追蹤性) → /ac-coverage
├── 用 TDD 開發(紅-綠-重構) → /tdd
├── 撰寫 BDD 場景(Given-When-Then) → /bdd
├── 與利害關係人定義驗收測試 → /atdd
└── 了解測試標準與最佳實踐 → /testing(此技能)
| 技能 | 焦點 |
|------|------|
| /testing | 測試標準與最佳實踐參考 |
| /coverage | 程式碼層級覆蓋率分析 |
| /ac-coverage | 需求層級 AC 可追蹤性 |
| /tdd | 紅-綠-重構開發循環 |
| /bdd | Given-When-Then 行為場景 |
| /atdd | 與利害關係人定義驗收條件 |
| 框架 | 層級 | 適用場景 | |-----------|--------|----------| | ISTQB | UT → IT/SIT → ST → AT/UAT | 企業級、合規性、正式 QA | | 業界通行金字塔 | UT (70%) → IT (20%) → E2E (10%) | 敏捷、DevOps、CI/CD |
整合測試縮寫說明:
┌─────────┐
│ E2E │ ← 10%(較少、較慢)
─┴─────────┴─
┌─────────────┐
│ IT/SIT │ ← 20%(整合測試)
─┴─────────────┴─
┌─────────────────┐
│ UT │ ← 70%(單元測試)
└─────────────────┘
| 層級 | 範圍 | 速度 | 相依性 | |-------|-------|-------|-------------| | UT | 單一函式/類別 | < 100ms | Mock | | IT/SIT | 元件互動 | 1-10秒 | 真實資料庫(容器化) | | ST | 完整系統(ISTQB) | 分鐘級 | 類生產環境 | | E2E | 使用者旅程 | 30秒+ | 所有真實環境 | | AT/UAT | 業務驗證(ISTQB) | 視情況 | 所有真實環境 |
| 指標 | 最低要求 | 建議值 | |--------|---------|-------------| | 行覆蓋率 | 70% | 85% | | 分支覆蓋率 | 60% | 80% | | 函式覆蓋率 | 80% | 90% |
完整標準請參考:
供 AI 助理使用,請採用 YAML 格式檔案以減少 Token 使用量:
ai/standards/testing.ai.yamlai/options/testing/istqb-framework.ai.yamlai/options/testing/industry-pyramid.ai.yamlai/options/testing/unit-testing.ai.yamlai/options/testing/integration-testing.ai.yamlai/options/testing/system-testing.ai.yamlai/options/testing/e2e-testing.ai.yaml[ClassName]Tests.cs # C#
[ClassName].test.ts # TypeScript
[class_name]_test.py # Python
[class_name]_test.go # Go
[MethodName]_[Scenario]_[ExpectedResult]()
should_[behavior]_when_[condition]()
test_[method]_[scenario]_[expected]()
| 類型 | 用途 | 使用時機 | |------|---------|-------------| | Stub | 回傳預定義值 | 固定 API 回應 | | Mock | 驗證互動 | 檢查方法是否被呼叫 | | Fake | 簡化實作 | 記憶體資料庫 | | Spy | 記錄呼叫、委派 | 部分 Mock |
test('method_scenario_expected', () => {
// Arrange - 設定測試資料
const input = createTestInput();
const sut = new SystemUnderTest();
// Act - 執行行為
const result = sut.execute(input);
// Assert - 驗證結果
expect(result).toBe(expected);
});
本 Skill 支援專案特定設定。
CONTRIBUTING.md 的「停用 Skills」區段
CONTRIBUTING.md 的「測試標準」區段若未找到設定且上下文不清楚時:
CONTRIBUTING.md 中記錄:## Testing Standards
### Coverage Targets
| Metric | Target |
|--------|--------|
| Line | 80% |
| Branch | 70% |
| Function | 85% |
在專案的 CONTRIBUTING.md 中:
## Testing Standards
### Coverage Targets
| Metric | Target |
|--------|--------|
| Line | 80% |
| Branch | 70% |
| Function | 85% |
### Testing Framework
- Unit Tests: Jest
- Integration Tests: Supertest
- E2E Tests: Playwright
| 版本 | 日期 | 變更內容 | |---------|------|---------| | 1.1.0 | 2025-12-29 | 新增:框架選擇(ISTQB/業界通行金字塔)、IT/SIT 縮寫說明 | | 1.0.0 | 2025-12-24 | 新增:標準區段(目的、相關標準、版本歷史、授權) |
本 Skill 以 CC BY 4.0 授權發布。
來源: universal-dev-standards
development
[UDS] 扫描代码库的调试残留与代码质量问题;可自动修正安全模式。 Use when: before committing, during PR review, or periodic codebase cleanup. Keywords: sweep, debug cleanup, console.log, debugger, TODO, ts-any, code quality, 扫描, 清理.
tools
[UDS] 从规格衍生 BDD 场景、TDD 骨架或 ATDD 表格
development
[UDS] 识别重复流程并以正确的开发深度构建 Skill
tools
[UDS] AI 辅助 git push 安全层:质量门禁 + 协作护栏。 Use when: pushing commits, force pushing, pushing to protected branches, pushing feature branches. Keywords: git push, force push, protected branch, quality gate, push receipt, PR automation, 推送, 保护分支, 质量门禁.