universal-dev-standards 6.14.0-beta.9 → 6.14.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/uds.js +12 -1
- package/bundled/ai/options/commit-message/traditional-chinese.ai.yaml +69 -67
- package/bundled/ai/standards/commit-message.ai.yaml +12 -2
- package/bundled/ai/standards/mock-boundary.ai.yaml +138 -2
- package/bundled/ai/standards/secret-management-standards.ai.yaml +12 -1
- package/bundled/ai/standards/turn-completion-integrity.ai.yaml +6 -2
- package/bundled/core/commit-message-guide.md +22 -19
- package/bundled/core/mock-boundary.md +70 -2
- package/bundled/core/secret-management-standards.md +13 -1
- package/bundled/core/turn-completion-integrity.md +8 -2
- package/bundled/extensions/locales/zh-tw.md +19 -19
- package/bundled/hooks/check-dangerous-cmd.mjs +161 -26
- package/bundled/hooks/check-logging-standard.mjs +35 -6
- package/bundled/hooks/validate-commit-msg.mjs +317 -28
- package/bundled/locales/zh-CN/CHANGELOG.md +2323 -1099
- package/bundled/locales/zh-CN/CLAUDE.md +987 -101
- package/bundled/locales/zh-CN/README.md +3 -3
- package/bundled/locales/zh-CN/SECURITY.md +4 -3
- package/bundled/locales/zh-CN/STANDARDS-MAPPING.md +103 -6
- package/bundled/locales/zh-CN/adoption/ADOPTION-GUIDE.md +68 -97
- package/bundled/locales/zh-CN/adoption/DAILY-WORKFLOW-GUIDE.md +2 -1
- package/bundled/locales/zh-CN/adoption/STATIC-DYNAMIC-GUIDE.md +8 -9
- package/bundled/locales/zh-CN/adoption/checklists/enterprise.md +81 -80
- package/bundled/locales/zh-CN/adoption/checklists/minimal.md +18 -14
- package/bundled/locales/zh-CN/adoption/checklists/recommended.md +49 -46
- package/bundled/locales/zh-CN/ai/MAINTENANCE.md +44 -9
- package/bundled/locales/zh-CN/ai/options/commit-message/traditional-chinese.ai.yaml +63 -55
- package/bundled/locales/zh-CN/core/acceptance-criteria-traceability.md +61 -14
- package/bundled/locales/zh-CN/core/acceptance-test-driven-development.md +2 -1
- package/bundled/locales/zh-CN/core/accessibility-standards.md +871 -62
- package/bundled/locales/zh-CN/core/adr-standards.md +155 -32
- package/bundled/locales/zh-CN/core/agent-communication-protocol.md +2 -1
- package/bundled/locales/zh-CN/core/agent-dispatch.md +68 -33
- package/bundled/locales/zh-CN/core/ai-agreement-standards.md +23 -22
- package/bundled/locales/zh-CN/core/ai-command-behavior.md +2 -1
- package/bundled/locales/zh-CN/core/ai-friendly-architecture.md +311 -72
- package/bundled/locales/zh-CN/core/ai-instruction-standards.md +71 -49
- package/bundled/locales/zh-CN/core/ai-response-navigation.md +2 -1
- package/bundled/locales/zh-CN/core/alerting-standards.md +231 -36
- package/bundled/locales/zh-CN/core/anti-hallucination.md +116 -697
- package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +34 -33
- package/bundled/locales/zh-CN/core/api-design-standards.md +144 -58
- package/bundled/locales/zh-CN/core/behavior-driven-development.md +2 -1
- package/bundled/locales/zh-CN/core/branch-completion.md +75 -20
- package/bundled/locales/zh-CN/core/capability-declaration.md +44 -94
- package/bundled/locales/zh-CN/core/change-batching-standards.md +2 -1
- package/bundled/locales/zh-CN/core/changelog-standards.md +485 -63
- package/bundled/locales/zh-CN/core/chaos-engineering-standards.md +141 -39
- package/bundled/locales/zh-CN/core/checkin-standards.md +176 -116
- package/bundled/locales/zh-CN/core/circuit-breaker.md +43 -77
- package/bundled/locales/zh-CN/core/code-review-checklist.md +37 -23
- package/bundled/locales/zh-CN/core/commit-message-guide.md +892 -69
- package/bundled/locales/zh-CN/core/containerization-standards.md +259 -57
- package/bundled/locales/zh-CN/core/context-aware-loading.md +103 -29
- package/bundled/locales/zh-CN/core/database-standards.md +115 -114
- package/bundled/locales/zh-CN/core/deprecation-standards.md +155 -40
- package/bundled/locales/zh-CN/core/design-document-standards.md +265 -55
- package/bundled/locales/zh-CN/core/developer-memory.md +150 -60
- package/bundled/locales/zh-CN/core/documentation-lifecycle.md +20 -16
- package/bundled/locales/zh-CN/core/documentation-structure.md +1284 -127
- package/bundled/locales/zh-CN/core/documentation-writing-standards.md +649 -259
- package/bundled/locales/zh-CN/core/dual-phase-output.md +37 -70
- package/bundled/locales/zh-CN/core/environment-standards.md +251 -73
- package/bundled/locales/zh-CN/core/error-code-standards.md +501 -60
- package/bundled/locales/zh-CN/core/estimation-standards.md +174 -41
- package/bundled/locales/zh-CN/core/execution-history.md +2 -1
- package/bundled/locales/zh-CN/core/failure-source-taxonomy.md +71 -84
- package/bundled/locales/zh-CN/core/feature-flag-standards.md +202 -57
- package/bundled/locales/zh-CN/core/forward-derivation-standards.md +613 -154
- package/bundled/locales/zh-CN/core/frontend-design-standards.md +361 -78
- package/bundled/locales/zh-CN/core/git-workflow.md +148 -262
- package/bundled/locales/zh-CN/core/git-worktree.md +59 -26
- package/bundled/locales/zh-CN/core/guides/file-placement-guide.md +132 -48
- package/bundled/locales/zh-CN/core/guides/performance-guide.md +61 -59
- package/bundled/locales/zh-CN/core/guides/security-guide.md +2 -0
- package/bundled/locales/zh-CN/core/health-check-standards.md +46 -104
- package/bundled/locales/zh-CN/core/immutability-first.md +83 -60
- package/bundled/locales/zh-CN/core/knowledge-transfer-standards.md +94 -31
- package/bundled/locales/zh-CN/core/mock-boundary.md +74 -6
- package/bundled/locales/zh-CN/core/mutation-testing.md +45 -6
- package/bundled/locales/zh-CN/core/observability-standards.md +281 -37
- package/bundled/locales/zh-CN/core/performance-standards.md +402 -42
- package/bundled/locales/zh-CN/core/pipeline-integration-standards.md +2 -1
- package/bundled/locales/zh-CN/core/postmortem-standards.md +358 -53
- package/bundled/locales/zh-CN/core/privacy-standards.md +148 -40
- package/bundled/locales/zh-CN/core/project-context-memory.md +182 -48
- package/bundled/locales/zh-CN/core/project-structure.md +550 -170
- package/bundled/locales/zh-CN/core/recovery-recipe-registry.md +54 -114
- package/bundled/locales/zh-CN/core/refactoring-standards.md +141 -556
- package/bundled/locales/zh-CN/core/requirement-engineering.md +7 -6
- package/bundled/locales/zh-CN/core/retrospective-standards.md +215 -22
- package/bundled/locales/zh-CN/core/retry-standards.md +46 -101
- package/bundled/locales/zh-CN/core/reverse-engineering-standards.md +370 -120
- package/bundled/locales/zh-CN/core/runbook-standards.md +294 -48
- package/bundled/locales/zh-CN/core/security-decision.md +45 -70
- package/bundled/locales/zh-CN/core/security-standards.md +169 -16
- package/bundled/locales/zh-CN/core/skill-standard-alignment-check.md +105 -71
- package/bundled/locales/zh-CN/core/slo-standards.md +296 -44
- package/bundled/locales/zh-CN/core/spec-driven-development.md +37 -6
- package/bundled/locales/zh-CN/core/standard-admission-criteria.md +25 -31
- package/bundled/locales/zh-CN/core/standard-lifecycle-management.md +49 -57
- package/bundled/locales/zh-CN/core/structured-task-definition.md +2 -1
- package/bundled/locales/zh-CN/core/supply-chain-security-standards.md +159 -32
- package/bundled/locales/zh-CN/core/systematic-debugging.md +87 -42
- package/bundled/locales/zh-CN/core/tech-debt-standards.md +202 -86
- package/bundled/locales/zh-CN/core/test-completeness-dimensions.md +262 -190
- package/bundled/locales/zh-CN/core/test-data-standards.md +252 -30
- package/bundled/locales/zh-CN/core/test-driven-development.md +21 -1022
- package/bundled/locales/zh-CN/core/test-governance.md +94 -43
- package/bundled/locales/zh-CN/core/testing-standards.md +83 -37
- package/bundled/locales/zh-CN/core/timeout-standards.md +45 -85
- package/bundled/locales/zh-CN/core/token-budget.md +44 -80
- package/bundled/locales/zh-CN/core/translation-lifecycle-standards.md +48 -36
- package/bundled/locales/zh-CN/core/turn-completion-integrity.md +8 -6
- package/bundled/locales/zh-CN/core/verification-evidence.md +44 -22
- package/bundled/locales/zh-CN/core/versioning.md +737 -73
- package/bundled/locales/zh-CN/core/virtual-organization-standards.md +30 -29
- package/bundled/locales/zh-CN/core/workflow-enforcement.md +9 -8
- package/bundled/locales/zh-CN/core/workflow-state-protocol.md +9 -8
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +2 -1
- package/bundled/locales/zh-CN/docs/CLI-FLOW.md +2 -1
- package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +19 -10
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +8 -6
- package/bundled/locales/zh-CN/docs/STANDARDS-REFERENCE.md +2 -1
- package/bundled/locales/zh-CN/docs/USAGE-MODES-COMPARISON.md +133 -132
- package/bundled/locales/zh-CN/docs/USER-MANUAL.md +11 -3
- package/bundled/locales/zh-CN/docs/WINDOWS-GUIDE.md +5 -2
- package/bundled/locales/zh-CN/docs/specs/system/memory-adoption-strategy.md +2 -0
- package/bundled/locales/zh-CN/docs/user/FAQ.md +2 -0
- package/bundled/locales/zh-CN/docs/user/GETTING-STARTED.md +2 -0
- package/bundled/locales/zh-CN/docs/user/GLOSSARY.md +2 -0
- package/bundled/locales/zh-CN/docs/user/README.md +4 -2
- package/bundled/locales/zh-CN/docs/user/TROUBLESHOOTING.md +2 -0
- package/bundled/locales/zh-CN/integrations/codex/AGENTS.md +136 -2
- package/bundled/locales/zh-CN/integrations/codex/README.md +62 -10
- package/bundled/locales/zh-CN/integrations/gemini-cli/GEMINI.md +59 -1
- package/bundled/locales/zh-CN/integrations/gemini-cli/README.md +9 -2
- package/bundled/locales/zh-CN/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +7 -1
- package/bundled/locales/zh-CN/integrations/github-copilot/README.md +8 -2
- package/bundled/locales/zh-CN/integrations/github-copilot/copilot-instructions.md +146 -12
- package/bundled/locales/zh-CN/integrations/github-copilot/skills-mapping.md +7 -1
- package/bundled/locales/zh-CN/integrations/google-antigravity/AGENTS.md +110 -3
- package/bundled/locales/zh-CN/integrations/google-antigravity/README.md +7 -1
- package/bundled/locales/zh-CN/integrations/opencode/AGENTS.md +140 -2
- package/bundled/locales/zh-CN/integrations/opencode/README.md +7 -1
- package/bundled/locales/zh-CN/integrations/opencode/skills-mapping.md +8 -2
- package/bundled/locales/zh-CN/integrations/openspec/AGENTS.md +46 -1
- package/bundled/locales/zh-CN/integrations/openspec/README.md +7 -1
- package/bundled/locales/zh-CN/integrations/spec-kit/AGENTS.md +20 -2
- package/bundled/locales/zh-CN/integrations/spec-kit/README.md +7 -1
- package/bundled/locales/zh-CN/options/changelog/auto-generated.md +2 -0
- package/bundled/locales/zh-CN/options/changelog/keep-a-changelog.md +2 -0
- package/bundled/locales/zh-CN/options/code-review/automated-review.md +2 -0
- package/bundled/locales/zh-CN/options/code-review/pair-programming.md +2 -0
- package/bundled/locales/zh-CN/options/commit-message/bilingual.md +139 -50
- package/bundled/locales/zh-CN/options/commit-message/english.md +159 -42
- package/bundled/locales/zh-CN/options/commit-message/traditional-chinese.md +156 -75
- package/bundled/locales/zh-CN/options/documentation/api-docs.md +3 -1
- package/bundled/locales/zh-CN/options/documentation/markdown-docs.md +2 -0
- package/bundled/locales/zh-CN/options/documentation/wiki-style.md +2 -0
- package/bundled/locales/zh-CN/options/git-workflow/gitflow.md +105 -77
- package/bundled/locales/zh-CN/options/git-workflow/github-flow.md +75 -57
- package/bundled/locales/zh-CN/options/git-workflow/merge-commit.md +155 -44
- package/bundled/locales/zh-CN/options/git-workflow/rebase-ff.md +168 -53
- package/bundled/locales/zh-CN/options/git-workflow/squash-merge.md +122 -37
- package/bundled/locales/zh-CN/options/git-workflow/trunk-based.md +108 -61
- package/bundled/locales/zh-CN/options/project-structure/dotnet.md +266 -47
- package/bundled/locales/zh-CN/options/project-structure/go.md +301 -43
- package/bundled/locales/zh-CN/options/project-structure/java.md +268 -48
- package/bundled/locales/zh-CN/options/project-structure/kotlin.md +2 -0
- package/bundled/locales/zh-CN/options/project-structure/nodejs.md +168 -51
- package/bundled/locales/zh-CN/options/project-structure/php.md +2 -0
- package/bundled/locales/zh-CN/options/project-structure/python.md +210 -52
- package/bundled/locales/zh-CN/options/project-structure/ruby.md +2 -0
- package/bundled/locales/zh-CN/options/project-structure/rust.md +2 -0
- package/bundled/locales/zh-CN/options/project-structure/swift.md +2 -0
- package/bundled/locales/zh-CN/options/testing/contract-testing.md +2 -0
- package/bundled/locales/zh-CN/options/testing/e2e-testing.md +227 -66
- package/bundled/locales/zh-CN/options/testing/industry-pyramid.md +2 -0
- package/bundled/locales/zh-CN/options/testing/integration-testing.md +185 -73
- package/bundled/locales/zh-CN/options/testing/istqb-framework.md +2 -0
- package/bundled/locales/zh-CN/options/testing/performance-testing.md +2 -0
- package/bundled/locales/zh-CN/options/testing/security-testing.md +2 -0
- package/bundled/locales/zh-CN/options/testing/system-testing.md +270 -96
- package/bundled/locales/zh-CN/options/testing/unit-testing.md +185 -71
- package/bundled/locales/zh-CN/skills/CONTRIBUTING.template.md +43 -42
- package/bundled/locales/zh-CN/skills/INTEGRATION-GUIDE.md +2 -1
- package/bundled/locales/zh-CN/skills/README.md +2 -1
- package/bundled/locales/zh-CN/skills/_shared/README.md +2 -1
- package/bundled/locales/zh-CN/skills/adr-assistant/guide.md +240 -4
- package/bundled/locales/zh-CN/skills/agents/README.md +180 -82
- package/bundled/locales/zh-CN/skills/agents/code-architect.md +3 -1
- package/bundled/locales/zh-CN/skills/agents/doc-writer.md +3 -1
- package/bundled/locales/zh-CN/skills/agents/reviewer.md +4 -2
- package/bundled/locales/zh-CN/skills/agents/spec-analyst.md +3 -1
- package/bundled/locales/zh-CN/skills/agents/test-specialist.md +3 -1
- package/bundled/locales/zh-CN/skills/ai-collaboration-standards/SKILL.md +91 -81
- package/bundled/locales/zh-CN/skills/ai-collaboration-standards/anti-hallucination.md +79 -59
- package/bundled/locales/zh-CN/skills/ai-collaboration-standards/certainty-labels.md +66 -40
- package/bundled/locales/zh-CN/skills/ai-friendly-architecture/SKILL.md +23 -36
- package/bundled/locales/zh-CN/skills/ai-instruction-standards/SKILL.md +217 -137
- package/bundled/locales/zh-CN/skills/api-design-assistant/SKILL.md +13 -2
- package/bundled/locales/zh-CN/skills/atdd-assistant/SKILL.md +16 -2
- package/bundled/locales/zh-CN/skills/atdd-assistant/acceptance-criteria-guide.md +2 -1
- package/bundled/locales/zh-CN/skills/atdd-assistant/atdd-workflow.md +98 -1
- package/bundled/locales/zh-CN/skills/atdd-assistant/guide.md +148 -132
- package/bundled/locales/zh-CN/skills/audit-assistant/SKILL.md +5 -2
- package/bundled/locales/zh-CN/skills/bdd-assistant/SKILL.md +16 -2
- package/bundled/locales/zh-CN/skills/bdd-assistant/bdd-workflow.md +2 -1
- package/bundled/locales/zh-CN/skills/bdd-assistant/gherkin-guide.md +2 -1
- package/bundled/locales/zh-CN/skills/bdd-assistant/guide.md +122 -121
- package/bundled/locales/zh-CN/skills/changelog-guide/SKILL.md +9 -2
- package/bundled/locales/zh-CN/skills/changelog-guide/guide.md +91 -88
- package/bundled/locales/zh-CN/skills/checkin-assistant/SKILL.md +12 -2
- package/bundled/locales/zh-CN/skills/checkin-assistant/guide.md +211 -210
- package/bundled/locales/zh-CN/skills/ci-cd-assistant/SKILL.md +14 -2
- package/bundled/locales/zh-CN/skills/code-review-assistant/SKILL.md +12 -2
- package/bundled/locales/zh-CN/skills/code-review-assistant/checkin-checklist.md +79 -78
- package/bundled/locales/zh-CN/skills/code-review-assistant/guide.md +119 -45
- package/bundled/locales/zh-CN/skills/code-review-assistant/review-checklist.md +89 -88
- package/bundled/locales/zh-CN/skills/commands/ac-coverage.md +43 -1
- package/bundled/locales/zh-CN/skills/commands/api-design.md +2 -1
- package/bundled/locales/zh-CN/skills/commands/atdd.md +71 -1
- package/bundled/locales/zh-CN/skills/commands/audit.md +2 -1
- package/bundled/locales/zh-CN/skills/commands/bdd.md +160 -62
- package/bundled/locales/zh-CN/skills/commands/changelog.md +36 -1
- package/bundled/locales/zh-CN/skills/commands/check.md +53 -1
- package/bundled/locales/zh-CN/skills/commands/checkin.md +45 -1
- package/bundled/locales/zh-CN/skills/commands/ci-cd.md +3 -2
- package/bundled/locales/zh-CN/skills/commands/code-review.md +41 -1
- package/bundled/locales/zh-CN/skills/commands/commit.md +56 -1
- package/bundled/locales/zh-CN/skills/commands/config.md +50 -1
- package/bundled/locales/zh-CN/skills/commands/coverage.md +43 -1
- package/bundled/locales/zh-CN/skills/commands/database.md +4 -3
- package/bundled/locales/zh-CN/skills/commands/derive-all.md +42 -1
- package/bundled/locales/zh-CN/skills/commands/derive-atdd.md +35 -1
- package/bundled/locales/zh-CN/skills/commands/derive-bdd.md +41 -1
- package/bundled/locales/zh-CN/skills/commands/derive-tdd.md +42 -1
- package/bundled/locales/zh-CN/skills/commands/derive.md +60 -4
- package/bundled/locales/zh-CN/skills/commands/dev-workflow.md +58 -8
- package/bundled/locales/zh-CN/skills/commands/discover.md +41 -1
- package/bundled/locales/zh-CN/skills/commands/docgen.md +37 -1
- package/bundled/locales/zh-CN/skills/commands/docs.md +136 -5
- package/bundled/locales/zh-CN/skills/commands/durable.md +4 -3
- package/bundled/locales/zh-CN/skills/commands/e2e.md +85 -1
- package/bundled/locales/zh-CN/skills/commands/guide.md +2 -1
- package/bundled/locales/zh-CN/skills/commands/incident.md +5 -4
- package/bundled/locales/zh-CN/skills/commands/init.md +57 -1
- package/bundled/locales/zh-CN/skills/commands/methodology.md +166 -77
- package/bundled/locales/zh-CN/skills/commands/metrics.md +3 -2
- package/bundled/locales/zh-CN/skills/commands/migrate.md +5 -4
- package/bundled/locales/zh-CN/skills/commands/observability.md +48 -3
- package/bundled/locales/zh-CN/skills/commands/pr.md +4 -3
- package/bundled/locales/zh-CN/skills/commands/refactor.md +76 -38
- package/bundled/locales/zh-CN/skills/commands/release.md +82 -1
- package/bundled/locales/zh-CN/skills/commands/requirement.md +40 -1
- package/bundled/locales/zh-CN/skills/commands/reverse-bdd.md +36 -1
- package/bundled/locales/zh-CN/skills/commands/reverse-sdd.md +44 -1
- package/bundled/locales/zh-CN/skills/commands/reverse-tdd.md +42 -1
- package/bundled/locales/zh-CN/skills/commands/reverse.md +43 -1
- package/bundled/locales/zh-CN/skills/commands/runbook.md +50 -3
- package/bundled/locales/zh-CN/skills/commands/scan.md +3 -2
- package/bundled/locales/zh-CN/skills/commands/sdd-retro.md +50 -1
- package/bundled/locales/zh-CN/skills/commands/sdd.md +182 -1
- package/bundled/locales/zh-CN/skills/commands/security.md +3 -2
- package/bundled/locales/zh-CN/skills/commands/slo.md +51 -3
- package/bundled/locales/zh-CN/skills/commands/tdd.md +74 -5
- package/bundled/locales/zh-CN/skills/commands/update.md +70 -8
- package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +4 -4
- package/bundled/locales/zh-CN/skills/commit-standards/conventional-commits.md +45 -44
- package/bundled/locales/zh-CN/skills/commit-standards/guide.md +172 -52
- package/bundled/locales/zh-CN/skills/commit-standards/language-options.md +50 -47
- package/bundled/locales/zh-CN/skills/contract-test-assistant/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/contract-test-assistant/guide.md +76 -1
- package/bundled/locales/zh-CN/skills/database-assistant/SKILL.md +18 -5
- package/bundled/locales/zh-CN/skills/dev-methodology/SKILL.md +4 -2
- package/bundled/locales/zh-CN/skills/dev-methodology/create-methodology.md +2 -0
- package/bundled/locales/zh-CN/skills/dev-methodology/runtime.md +2 -0
- package/bundled/locales/zh-CN/skills/docs-generator/SKILL.md +16 -2
- package/bundled/locales/zh-CN/skills/docs-generator/guide.md +8 -7
- package/bundled/locales/zh-CN/skills/documentation-guide/SKILL.md +209 -184
- package/bundled/locales/zh-CN/skills/documentation-guide/documentation-structure.md +73 -72
- package/bundled/locales/zh-CN/skills/documentation-guide/readme-template.md +37 -36
- package/bundled/locales/zh-CN/skills/durable-execution-assistant/SKILL.md +28 -2
- package/bundled/locales/zh-CN/skills/e2e-assistant/SKILL.md +21 -6
- package/bundled/locales/zh-CN/skills/error-code-guide/SKILL.md +76 -95
- package/bundled/locales/zh-CN/skills/git-workflow-guide/SKILL.md +80 -87
- package/bundled/locales/zh-CN/skills/git-workflow-guide/branch-naming.md +44 -43
- package/bundled/locales/zh-CN/skills/git-workflow-guide/git-workflow.md +66 -65
- package/bundled/locales/zh-CN/skills/incident-response-assistant/SKILL.md +31 -13
- package/bundled/locales/zh-CN/skills/metrics-dashboard-assistant/SKILL.md +38 -2
- package/bundled/locales/zh-CN/skills/observability-assistant/SKILL.md +75 -1
- package/bundled/locales/zh-CN/skills/pr-automation-assistant/SKILL.md +32 -6
- package/bundled/locales/zh-CN/skills/project-discovery/SKILL.md +8 -2
- package/bundled/locales/zh-CN/skills/project-discovery/guide.md +158 -157
- package/bundled/locales/zh-CN/skills/project-structure-guide/SKILL.md +49 -46
- package/bundled/locales/zh-CN/skills/project-structure-guide/language-patterns.md +8 -7
- package/bundled/locales/zh-CN/skills/refactoring-assistant/SKILL.md +22 -2
- package/bundled/locales/zh-CN/skills/refactoring-assistant/guide.md +172 -171
- package/bundled/locales/zh-CN/skills/release-standards/SKILL.md +66 -23
- package/bundled/locales/zh-CN/skills/release-standards/changelog-format.md +42 -41
- package/bundled/locales/zh-CN/skills/release-standards/guide.md +51 -43
- package/bundled/locales/zh-CN/skills/release-standards/release-workflow.md +131 -95
- package/bundled/locales/zh-CN/skills/release-standards/semantic-versioning.md +62 -61
- package/bundled/locales/zh-CN/skills/requirement-assistant/SKILL.md +24 -15
- package/bundled/locales/zh-CN/skills/requirement-assistant/guide.md +88 -79
- package/bundled/locales/zh-CN/skills/requirement-assistant/requirement-checklist.md +128 -127
- package/bundled/locales/zh-CN/skills/requirement-assistant/requirement-writing.md +121 -120
- package/bundled/locales/zh-CN/skills/retrospective-assistant/guide.md +206 -2
- package/bundled/locales/zh-CN/skills/reverse-engineer/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/reverse-engineer/bdd-extraction.md +2 -1
- package/bundled/locales/zh-CN/skills/reverse-engineer/guide.md +297 -173
- package/bundled/locales/zh-CN/skills/reverse-engineer/tdd-analysis.md +2 -1
- package/bundled/locales/zh-CN/skills/reverse-engineer/workflow.md +2 -1
- package/bundled/locales/zh-CN/skills/runbook-assistant/SKILL.md +9 -2
- package/bundled/locales/zh-CN/skills/security-assistant/SKILL.md +24 -6
- package/bundled/locales/zh-CN/skills/security-scan-assistant/SKILL.md +34 -10
- package/bundled/locales/zh-CN/skills/slo-assistant/SKILL.md +2 -1
- package/bundled/locales/zh-CN/skills/spec-derivation/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/spec-driven-dev/guide.md +38 -6
- package/bundled/locales/zh-CN/skills/tdd-assistant/SKILL.md +16 -3
- package/bundled/locales/zh-CN/skills/tdd-assistant/guide.md +217 -156
- package/bundled/locales/zh-CN/skills/tdd-assistant/language-examples.md +727 -82
- package/bundled/locales/zh-CN/skills/tdd-assistant/tdd-workflow.md +396 -214
- package/bundled/locales/zh-CN/skills/test-coverage-assistant/SKILL.md +14 -5
- package/bundled/locales/zh-CN/skills/test-coverage-assistant/guide.md +25 -12
- package/bundled/locales/zh-CN/skills/testing-guide/testing-pyramid.md +99 -98
- package/bundled/locales/zh-CN/skills/testing-guide/testing-theory.md +3 -1
- package/bundled/locales/zh-CN/skills/tools/cline/README.md +2 -1
- package/bundled/locales/zh-CN/skills/tools/copilot/README.md +65 -18
- package/bundled/locales/zh-CN/skills/tools/copilot/copilot-instructions.md +2 -1
- package/bundled/locales/zh-CN/skills/tools/cursor/README.md +2 -1
- package/bundled/locales/zh-CN/skills/tools/windsurf/README.md +2 -1
- package/bundled/locales/zh-CN/skills/workflows/README.md +4 -2
- package/bundled/locales/zh-CN/templates/reverse-spec-template.md +50 -1
- package/bundled/locales/zh-TW/CHANGELOG.md +2323 -1128
- package/bundled/locales/zh-TW/CLAUDE.md +962 -76
- package/bundled/locales/zh-TW/README.md +3 -3
- package/bundled/locales/zh-TW/SECURITY.md +4 -3
- package/bundled/locales/zh-TW/STANDARDS-MAPPING.md +103 -6
- package/bundled/locales/zh-TW/adoption/ADOPTION-GUIDE.md +46 -93
- package/bundled/locales/zh-TW/adoption/DAILY-WORKFLOW-GUIDE.md +2 -1
- package/bundled/locales/zh-TW/adoption/STATIC-DYNAMIC-GUIDE.md +3 -1
- package/bundled/locales/zh-TW/adoption/checklists/enterprise.md +10 -9
- package/bundled/locales/zh-TW/adoption/checklists/minimal.md +6 -2
- package/bundled/locales/zh-TW/adoption/checklists/recommended.md +7 -4
- package/bundled/locales/zh-TW/ai/MAINTENANCE.md +34 -14
- package/bundled/locales/zh-TW/ai/options/commit-message/traditional-chinese.ai.yaml +48 -40
- package/bundled/locales/zh-TW/core/acceptance-criteria-traceability.md +56 -10
- package/bundled/locales/zh-TW/core/acceptance-test-driven-development.md +2 -1
- package/bundled/locales/zh-TW/core/accessibility-standards.md +895 -46
- package/bundled/locales/zh-TW/core/adr-standards.md +2 -1
- package/bundled/locales/zh-TW/core/agent-communication-protocol.md +2 -1
- package/bundled/locales/zh-TW/core/agent-dispatch.md +102 -33
- package/bundled/locales/zh-TW/core/ai-agreement-standards.md +58 -41
- package/bundled/locales/zh-TW/core/ai-command-behavior.md +2 -1
- package/bundled/locales/zh-TW/core/ai-friendly-architecture.md +306 -67
- package/bundled/locales/zh-TW/core/ai-instruction-standards.md +16 -13
- package/bundled/locales/zh-TW/core/ai-response-navigation.md +3 -3
- package/bundled/locales/zh-TW/core/alerting-standards.md +257 -35
- package/bundled/locales/zh-TW/core/anti-hallucination.md +169 -40
- package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +2 -1
- package/bundled/locales/zh-TW/core/api-design-standards.md +2 -1
- package/bundled/locales/zh-TW/core/behavior-driven-development.md +3 -17
- package/bundled/locales/zh-TW/core/branch-completion.md +130 -34
- package/bundled/locales/zh-TW/core/capability-declaration.md +41 -79
- package/bundled/locales/zh-TW/core/change-batching-standards.md +2 -1
- package/bundled/locales/zh-TW/core/changelog-standards.md +14 -9
- package/bundled/locales/zh-TW/core/chaos-engineering-standards.md +138 -36
- package/bundled/locales/zh-TW/core/checkin-standards.md +84 -26
- package/bundled/locales/zh-TW/core/circuit-breaker.md +48 -87
- package/bundled/locales/zh-TW/core/code-review-checklist.md +19 -7
- package/bundled/locales/zh-TW/core/commit-message-guide.md +218 -87
- package/bundled/locales/zh-TW/core/containerization-standards.md +259 -57
- package/bundled/locales/zh-TW/core/context-aware-loading.md +121 -27
- package/bundled/locales/zh-TW/core/database-standards.md +2 -1
- package/bundled/locales/zh-TW/core/deprecation-standards.md +139 -37
- package/bundled/locales/zh-TW/core/design-document-standards.md +265 -55
- package/bundled/locales/zh-TW/core/developer-memory.md +102 -12
- package/bundled/locales/zh-TW/core/documentation-lifecycle.md +2 -1
- package/bundled/locales/zh-TW/core/documentation-structure.md +17 -8
- package/bundled/locales/zh-TW/core/dual-phase-output.md +28 -90
- package/bundled/locales/zh-TW/core/environment-standards.md +250 -72
- package/bundled/locales/zh-TW/core/error-code-standards.md +17 -6
- package/bundled/locales/zh-TW/core/estimation-standards.md +177 -44
- package/bundled/locales/zh-TW/core/execution-history.md +2 -1
- package/bundled/locales/zh-TW/core/failure-source-taxonomy.md +59 -117
- package/bundled/locales/zh-TW/core/feature-flag-standards.md +202 -57
- package/bundled/locales/zh-TW/core/forward-derivation-standards.md +592 -133
- package/bundled/locales/zh-TW/core/frontend-design-standards.md +120 -8
- package/bundled/locales/zh-TW/core/git-workflow.md +197 -37
- package/bundled/locales/zh-TW/core/git-worktree.md +79 -49
- package/bundled/locales/zh-TW/core/guides/anti-hallucination-guide.md +234 -487
- package/bundled/locales/zh-TW/core/guides/file-placement-guide.md +86 -2
- package/bundled/locales/zh-TW/core/guides/git-workflow-guide.md +411 -464
- package/bundled/locales/zh-TW/core/guides/performance-guide.md +2 -0
- package/bundled/locales/zh-TW/core/guides/refactoring-guide.md +237 -484
- package/bundled/locales/zh-TW/core/guides/security-guide.md +2 -0
- package/bundled/locales/zh-TW/core/health-check-standards.md +46 -104
- package/bundled/locales/zh-TW/core/immutability-first.md +45 -85
- package/bundled/locales/zh-TW/core/knowledge-graph-memory.md +2 -1
- package/bundled/locales/zh-TW/core/knowledge-transfer-standards.md +103 -40
- package/bundled/locales/zh-TW/core/mock-boundary.md +74 -6
- package/bundled/locales/zh-TW/core/observability-standards.md +284 -40
- package/bundled/locales/zh-TW/core/performance-standards.md +387 -86
- package/bundled/locales/zh-TW/core/pipeline-integration-standards.md +2 -1
- package/bundled/locales/zh-TW/core/postmortem-standards.md +367 -36
- package/bundled/locales/zh-TW/core/privacy-standards.md +153 -46
- package/bundled/locales/zh-TW/core/project-context-memory.md +210 -31
- package/bundled/locales/zh-TW/core/project-structure.md +240 -19
- package/bundled/locales/zh-TW/core/recovery-recipe-registry.md +54 -114
- package/bundled/locales/zh-TW/core/refactoring-standards.md +153 -48
- package/bundled/locales/zh-TW/core/requirement-engineering.md +8 -37
- package/bundled/locales/zh-TW/core/retrospective-standards.md +127 -7
- package/bundled/locales/zh-TW/core/retry-standards.md +41 -105
- package/bundled/locales/zh-TW/core/reverse-engineering-standards.md +5 -1
- package/bundled/locales/zh-TW/core/runbook-standards.md +296 -23
- package/bundled/locales/zh-TW/core/secret-management-standards.md +12 -4
- package/bundled/locales/zh-TW/core/security-decision.md +43 -84
- package/bundled/locales/zh-TW/core/security-standards.md +204 -25
- package/bundled/locales/zh-TW/core/self-review-protocol.md +2 -1
- package/bundled/locales/zh-TW/core/skill-standard-alignment-check.md +103 -69
- package/bundled/locales/zh-TW/core/slo-standards.md +301 -49
- package/bundled/locales/zh-TW/core/spec-driven-development.md +36 -7
- package/bundled/locales/zh-TW/core/standard-admission-criteria.md +22 -28
- package/bundled/locales/zh-TW/core/standard-lifecycle-management.md +40 -48
- package/bundled/locales/zh-TW/core/structured-task-definition.md +2 -1
- package/bundled/locales/zh-TW/core/supply-chain-security-standards.md +137 -10
- package/bundled/locales/zh-TW/core/systematic-debugging.md +94 -38
- package/bundled/locales/zh-TW/core/tech-debt-standards.md +170 -54
- package/bundled/locales/zh-TW/core/test-completeness-dimensions.md +101 -12
- package/bundled/locales/zh-TW/core/test-data-standards.md +245 -23
- package/bundled/locales/zh-TW/core/test-driven-development.md +4 -1
- package/bundled/locales/zh-TW/core/test-governance.md +92 -32
- package/bundled/locales/zh-TW/core/testing-standards.md +61 -14
- package/bundled/locales/zh-TW/core/timeout-standards.md +45 -85
- package/bundled/locales/zh-TW/core/token-budget.md +41 -112
- package/bundled/locales/zh-TW/core/translation-lifecycle-standards.md +28 -16
- package/bundled/locales/zh-TW/core/turn-completion-integrity.md +8 -6
- package/bundled/locales/zh-TW/core/verification-evidence.md +2 -1
- package/bundled/locales/zh-TW/core/versioning.md +6 -2
- package/bundled/locales/zh-TW/core/virtual-organization-standards.md +42 -36
- package/bundled/locales/zh-TW/core/workflow-enforcement.md +2 -1
- package/bundled/locales/zh-TW/core/workflow-state-protocol.md +2 -1
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +2 -1
- package/bundled/locales/zh-TW/docs/CLI-FLOW.md +2 -1
- package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +12 -3
- package/bundled/locales/zh-TW/docs/DEV-WORKFLOW-MAPPING.md +2 -1
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +8 -6
- package/bundled/locales/zh-TW/docs/STANDARDS-REFERENCE.md +2 -1
- package/bundled/locales/zh-TW/docs/USAGE-MODES-COMPARISON.md +2 -1
- package/bundled/locales/zh-TW/docs/USER-MANUAL.md +9 -1
- package/bundled/locales/zh-TW/docs/WINDOWS-GUIDE.md +4 -1
- package/bundled/locales/zh-TW/docs/specs/system/memory-adoption-strategy.md +2 -0
- package/bundled/locales/zh-TW/docs/user/FAQ.md +2 -0
- package/bundled/locales/zh-TW/docs/user/GETTING-STARTED.md +2 -0
- package/bundled/locales/zh-TW/docs/user/GLOSSARY.md +2 -0
- package/bundled/locales/zh-TW/docs/user/README.md +2 -0
- package/bundled/locales/zh-TW/docs/user/TROUBLESHOOTING.md +2 -0
- package/bundled/locales/zh-TW/integrations/claude-code/README.md +2 -1
- package/bundled/locales/zh-TW/integrations/codex/AGENTS.md +136 -2
- package/bundled/locales/zh-TW/integrations/codex/README.md +7 -1
- package/bundled/locales/zh-TW/integrations/gemini-cli/GEMINI.md +59 -1
- package/bundled/locales/zh-TW/integrations/gemini-cli/README.md +8 -1
- package/bundled/locales/zh-TW/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +7 -1
- package/bundled/locales/zh-TW/integrations/github-copilot/README.md +9 -3
- package/bundled/locales/zh-TW/integrations/github-copilot/copilot-instructions.md +146 -12
- package/bundled/locales/zh-TW/integrations/github-copilot/skills-mapping.md +7 -1
- package/bundled/locales/zh-TW/integrations/google-antigravity/AGENTS.md +110 -3
- package/bundled/locales/zh-TW/integrations/google-antigravity/README.md +7 -1
- package/bundled/locales/zh-TW/integrations/opencode/AGENTS.md +140 -2
- package/bundled/locales/zh-TW/integrations/opencode/README.md +7 -1
- package/bundled/locales/zh-TW/integrations/opencode/skills-mapping.md +8 -2
- package/bundled/locales/zh-TW/integrations/openspec/AGENTS.md +46 -1
- package/bundled/locales/zh-TW/integrations/openspec/README.md +7 -1
- package/bundled/locales/zh-TW/integrations/spec-kit/AGENTS.md +20 -2
- package/bundled/locales/zh-TW/integrations/spec-kit/README.md +7 -1
- package/bundled/locales/zh-TW/methodologies/guides/tdd-guide.md +584 -475
- package/bundled/locales/zh-TW/options/changelog/auto-generated.md +2 -0
- package/bundled/locales/zh-TW/options/changelog/keep-a-changelog.md +2 -0
- package/bundled/locales/zh-TW/options/code-review/automated-review.md +2 -0
- package/bundled/locales/zh-TW/options/code-review/pair-programming.md +2 -0
- package/bundled/locales/zh-TW/options/commit-message/bilingual.md +93 -5
- package/bundled/locales/zh-TW/options/commit-message/english.md +118 -1
- package/bundled/locales/zh-TW/options/commit-message/traditional-chinese.md +82 -1
- package/bundled/locales/zh-TW/options/documentation/api-docs.md +2 -0
- package/bundled/locales/zh-TW/options/documentation/markdown-docs.md +2 -0
- package/bundled/locales/zh-TW/options/documentation/wiki-style.md +2 -0
- package/bundled/locales/zh-TW/options/git-workflow/gitflow.md +99 -71
- package/bundled/locales/zh-TW/options/git-workflow/github-flow.md +68 -50
- package/bundled/locales/zh-TW/options/git-workflow/merge-commit.md +131 -20
- package/bundled/locales/zh-TW/options/git-workflow/rebase-ff.md +142 -27
- package/bundled/locales/zh-TW/options/git-workflow/squash-merge.md +100 -15
- package/bundled/locales/zh-TW/options/git-workflow/trunk-based.md +103 -56
- package/bundled/locales/zh-TW/options/project-structure/dotnet.md +233 -14
- package/bundled/locales/zh-TW/options/project-structure/go.md +270 -12
- package/bundled/locales/zh-TW/options/project-structure/java.md +235 -15
- package/bundled/locales/zh-TW/options/project-structure/kotlin.md +2 -0
- package/bundled/locales/zh-TW/options/project-structure/nodejs.md +136 -19
- package/bundled/locales/zh-TW/options/project-structure/php.md +2 -0
- package/bundled/locales/zh-TW/options/project-structure/python.md +177 -19
- package/bundled/locales/zh-TW/options/project-structure/ruby.md +2 -0
- package/bundled/locales/zh-TW/options/project-structure/rust.md +2 -0
- package/bundled/locales/zh-TW/options/project-structure/swift.md +2 -0
- package/bundled/locales/zh-TW/options/testing/contract-testing.md +2 -0
- package/bundled/locales/zh-TW/options/testing/e2e-testing.md +182 -21
- package/bundled/locales/zh-TW/options/testing/industry-pyramid.md +2 -0
- package/bundled/locales/zh-TW/options/testing/integration-testing.md +134 -22
- package/bundled/locales/zh-TW/options/testing/istqb-framework.md +2 -0
- package/bundled/locales/zh-TW/options/testing/performance-testing.md +2 -0
- package/bundled/locales/zh-TW/options/testing/security-testing.md +2 -0
- package/bundled/locales/zh-TW/options/testing/system-testing.md +175 -1
- package/bundled/locales/zh-TW/options/testing/unit-testing.md +123 -9
- package/bundled/locales/zh-TW/skills/CONTRIBUTING.template.md +3 -2
- package/bundled/locales/zh-TW/skills/INTEGRATION-GUIDE.md +2 -1
- package/bundled/locales/zh-TW/skills/README.md +2 -1
- package/bundled/locales/zh-TW/skills/_shared/README.md +2 -1
- package/bundled/locales/zh-TW/skills/ac-coverage/SKILL.md +15 -4
- package/bundled/locales/zh-TW/skills/adr-assistant/guide.md +123 -3
- package/bundled/locales/zh-TW/skills/agents/README.md +99 -1
- package/bundled/locales/zh-TW/skills/agents/code-architect.md +2 -0
- package/bundled/locales/zh-TW/skills/agents/doc-writer.md +2 -0
- package/bundled/locales/zh-TW/skills/agents/reviewer.md +3 -1
- package/bundled/locales/zh-TW/skills/agents/spec-analyst.md +2 -0
- package/bundled/locales/zh-TW/skills/agents/test-specialist.md +2 -0
- package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +48 -37
- package/bundled/locales/zh-TW/skills/ai-collaboration-standards/anti-hallucination.md +22 -2
- package/bundled/locales/zh-TW/skills/ai-collaboration-standards/certainty-labels.md +29 -3
- package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +23 -36
- package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +12 -36
- package/bundled/locales/zh-TW/skills/api-design-assistant/SKILL.md +21 -5
- package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +40 -15
- package/bundled/locales/zh-TW/skills/atdd-assistant/acceptance-criteria-guide.md +2 -1
- package/bundled/locales/zh-TW/skills/atdd-assistant/atdd-workflow.md +98 -1
- package/bundled/locales/zh-TW/skills/atdd-assistant/guide.md +24 -8
- package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +8 -2
- package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +29 -6
- package/bundled/locales/zh-TW/skills/bdd-assistant/bdd-workflow.md +2 -1
- package/bundled/locales/zh-TW/skills/bdd-assistant/gherkin-guide.md +2 -1
- package/bundled/locales/zh-TW/skills/bdd-assistant/guide.md +9 -8
- package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +12 -3
- package/bundled/locales/zh-TW/skills/changelog-guide/guide.md +11 -7
- package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +19 -3
- package/bundled/locales/zh-TW/skills/checkin-assistant/guide.md +5 -3
- package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +35 -16
- package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +19 -2
- package/bundled/locales/zh-TW/skills/code-review-assistant/checkin-checklist.md +2 -1
- package/bundled/locales/zh-TW/skills/code-review-assistant/guide.md +81 -6
- package/bundled/locales/zh-TW/skills/code-review-assistant/review-checklist.md +2 -1
- package/bundled/locales/zh-TW/skills/commands/ac-coverage.md +47 -2
- package/bundled/locales/zh-TW/skills/commands/api-design.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/atdd.md +80 -10
- package/bundled/locales/zh-TW/skills/commands/audit.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/bdd.md +114 -16
- package/bundled/locales/zh-TW/skills/commands/changelog.md +45 -9
- package/bundled/locales/zh-TW/skills/commands/check.md +74 -21
- package/bundled/locales/zh-TW/skills/commands/checkin.md +56 -11
- package/bundled/locales/zh-TW/skills/commands/ci-cd.md +2 -1
- package/bundled/locales/zh-TW/skills/commands/code-review.md +43 -2
- package/bundled/locales/zh-TW/skills/commands/commit.md +58 -4
- package/bundled/locales/zh-TW/skills/commands/config.md +52 -4
- package/bundled/locales/zh-TW/skills/commands/coverage.md +45 -4
- package/bundled/locales/zh-TW/skills/commands/database.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/derive-all.md +44 -2
- package/bundled/locales/zh-TW/skills/commands/derive-atdd.md +37 -2
- package/bundled/locales/zh-TW/skills/commands/derive-bdd.md +44 -3
- package/bundled/locales/zh-TW/skills/commands/derive-tdd.md +45 -3
- package/bundled/locales/zh-TW/skills/commands/derive.md +62 -5
- package/bundled/locales/zh-TW/skills/commands/dev-workflow.md +60 -9
- package/bundled/locales/zh-TW/skills/commands/discover.md +43 -2
- package/bundled/locales/zh-TW/skills/commands/docgen.md +39 -2
- package/bundled/locales/zh-TW/skills/commands/docs.md +139 -7
- package/bundled/locales/zh-TW/skills/commands/durable.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/e2e.md +86 -3
- package/bundled/locales/zh-TW/skills/commands/guide.md +4 -2
- package/bundled/locales/zh-TW/skills/commands/incident.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/init.md +72 -15
- package/bundled/locales/zh-TW/skills/commands/methodology.md +117 -28
- package/bundled/locales/zh-TW/skills/commands/metrics.md +2 -1
- package/bundled/locales/zh-TW/skills/commands/migrate.md +2 -1
- package/bundled/locales/zh-TW/skills/commands/observability.md +45 -2
- package/bundled/locales/zh-TW/skills/commands/pr.md +2 -1
- package/bundled/locales/zh-TW/skills/commands/refactor.md +54 -13
- package/bundled/locales/zh-TW/skills/commands/release.md +83 -2
- package/bundled/locales/zh-TW/skills/commands/requirement.md +41 -2
- package/bundled/locales/zh-TW/skills/commands/reverse-bdd.md +37 -2
- package/bundled/locales/zh-TW/skills/commands/reverse-sdd.md +45 -2
- package/bundled/locales/zh-TW/skills/commands/reverse-tdd.md +43 -2
- package/bundled/locales/zh-TW/skills/commands/reverse.md +44 -2
- package/bundled/locales/zh-TW/skills/commands/runbook.md +47 -2
- package/bundled/locales/zh-TW/skills/commands/scan.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/sdd-retro.md +52 -3
- package/bundled/locales/zh-TW/skills/commands/sdd.md +209 -28
- package/bundled/locales/zh-TW/skills/commands/security.md +3 -2
- package/bundled/locales/zh-TW/skills/commands/slo.md +48 -2
- package/bundled/locales/zh-TW/skills/commands/tdd.md +71 -2
- package/bundled/locales/zh-TW/skills/commands/update.md +64 -2
- package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/commit-standards/conventional-commits.md +2 -1
- package/bundled/locales/zh-TW/skills/commit-standards/guide.md +137 -17
- package/bundled/locales/zh-TW/skills/commit-standards/language-options.md +21 -18
- package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/contract-test-assistant/guide.md +81 -1
- package/bundled/locales/zh-TW/skills/database-assistant/SKILL.md +21 -5
- package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +2 -1
- package/bundled/locales/zh-TW/skills/dev-methodology/SKILL.md +4 -1
- package/bundled/locales/zh-TW/skills/dev-methodology/create-methodology.md +2 -0
- package/bundled/locales/zh-TW/skills/dev-methodology/runtime.md +2 -0
- package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +19 -2
- package/bundled/locales/zh-TW/skills/docs-generator/guide.md +4 -3
- package/bundled/locales/zh-TW/skills/documentation-guide/SKILL.md +67 -42
- package/bundled/locales/zh-TW/skills/documentation-guide/documentation-structure.md +2 -1
- package/bundled/locales/zh-TW/skills/documentation-guide/readme-template.md +2 -1
- package/bundled/locales/zh-TW/skills/durable-execution-assistant/SKILL.md +32 -3
- package/bundled/locales/zh-TW/skills/e2e-assistant/SKILL.md +25 -7
- package/bundled/locales/zh-TW/skills/error-code-guide/SKILL.md +17 -34
- package/bundled/locales/zh-TW/skills/git-workflow-guide/SKILL.md +33 -38
- package/bundled/locales/zh-TW/skills/git-workflow-guide/branch-naming.md +2 -1
- package/bundled/locales/zh-TW/skills/git-workflow-guide/git-workflow.md +2 -1
- package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +35 -14
- package/bundled/locales/zh-TW/skills/journey-test-assistant/SKILL.md +2 -14
- package/bundled/locales/zh-TW/skills/knowledge-graph/SKILL.md +6 -2
- package/bundled/locales/zh-TW/skills/metrics-dashboard-assistant/SKILL.md +42 -3
- package/bundled/locales/zh-TW/skills/observability-assistant/SKILL.md +85 -18
- package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +27 -3
- package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +11 -3
- package/bundled/locales/zh-TW/skills/project-discovery/guide.md +5 -3
- package/bundled/locales/zh-TW/skills/project-discovery/workflow.md +2 -1
- package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +19 -16
- package/bundled/locales/zh-TW/skills/project-structure-guide/language-patterns.md +2 -1
- package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +26 -3
- package/bundled/locales/zh-TW/skills/refactoring-assistant/guide.md +4 -2
- package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +91 -45
- package/bundled/locales/zh-TW/skills/release-standards/changelog-format.md +4 -3
- package/bundled/locales/zh-TW/skills/release-standards/guide.md +14 -5
- package/bundled/locales/zh-TW/skills/release-standards/release-workflow.md +5 -1
- package/bundled/locales/zh-TW/skills/release-standards/semantic-versioning.md +2 -1
- package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +15 -6
- package/bundled/locales/zh-TW/skills/requirement-assistant/guide.md +18 -8
- package/bundled/locales/zh-TW/skills/requirement-assistant/requirement-checklist.md +2 -1
- package/bundled/locales/zh-TW/skills/requirement-assistant/requirement-writing.md +2 -1
- package/bundled/locales/zh-TW/skills/retrospective-assistant/guide.md +200 -6
- package/bundled/locales/zh-TW/skills/reverse-engineer/bdd-extraction.md +2 -1
- package/bundled/locales/zh-TW/skills/reverse-engineer/guide.md +161 -36
- package/bundled/locales/zh-TW/skills/reverse-engineer/tdd-analysis.md +2 -1
- package/bundled/locales/zh-TW/skills/reverse-engineer/workflow.md +2 -1
- package/bundled/locales/zh-TW/skills/runbook-assistant/SKILL.md +9 -1
- package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +25 -5
- package/bundled/locales/zh-TW/skills/security-scan-assistant/SKILL.md +34 -8
- package/bundled/locales/zh-TW/skills/skill-builder/SKILL.md +3 -21
- package/bundled/locales/zh-TW/skills/slo-assistant/SKILL.md +3 -1
- package/bundled/locales/zh-TW/skills/spec-derivation/SKILL.md +2 -1
- package/bundled/locales/zh-TW/skills/spec-driven-dev/guide.md +35 -2
- package/bundled/locales/zh-TW/skills/sweep/SKILL.md +2 -1
- package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +10 -2
- package/bundled/locales/zh-TW/skills/tdd-assistant/guide.md +68 -9
- package/bundled/locales/zh-TW/skills/tdd-assistant/language-examples.md +693 -47
- package/bundled/locales/zh-TW/skills/tdd-assistant/tdd-workflow.md +183 -1
- package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +15 -5
- package/bundled/locales/zh-TW/skills/test-coverage-assistant/guide.md +26 -13
- package/bundled/locales/zh-TW/skills/testing-guide/testing-pyramid.md +2 -1
- package/bundled/locales/zh-TW/skills/testing-guide/testing-theory.md +3 -1
- package/bundled/locales/zh-TW/skills/tools/cline/README.md +2 -1
- package/bundled/locales/zh-TW/skills/tools/copilot/README.md +65 -18
- package/bundled/locales/zh-TW/skills/tools/copilot/copilot-instructions.md +2 -1
- package/bundled/locales/zh-TW/skills/tools/cursor/README.md +2 -1
- package/bundled/locales/zh-TW/skills/tools/windsurf/README.md +2 -1
- package/bundled/locales/zh-TW/skills/workflows/README.md +11 -9
- package/bundled/locales/zh-TW/templates/reverse-spec-template.md +50 -1
- package/bundled/skills/.claude-plugin/plugin.json +71 -0
- package/bundled/skills/commit-standards/SKILL.md +2 -2
- package/bundled/skills/commit-standards/guide.md +3 -2
- package/bundled/skills/commit-standards/language-options.md +19 -17
- package/package.json +2 -2
- package/src/commands/audit.js +28 -1
- package/src/commands/check.js +72 -3
- package/src/commands/compile.js +37 -4
- package/src/commands/config.js +49 -24
- package/src/commands/init.js +78 -30
- package/src/commands/open-work.js +6 -2
- package/src/commands/release-messages.js +228 -0
- package/src/commands/release.js +127 -68
- package/src/commands/run-intent.js +11 -0
- package/src/commands/spec.js +4 -2
- package/src/commands/update.js +227 -47
- package/src/compilers/claude-code-compiler.js +9 -1
- package/src/config/ai-agent-paths.js +14 -1
- package/src/core/installed-formats.js +15 -0
- package/src/core/open-work-config.js +20 -1
- package/src/core/project-config.js +55 -0
- package/src/i18n/messages.js +106 -2
- package/src/installers/hooks-installer.js +1 -1
- package/src/installers/manifest-installer.js +1 -1
- package/src/installers/skills-installer.js +1 -1
- package/src/installers/standards-installer.js +3 -1
- package/src/mcp/server.js +9 -3
- package/src/prompts/init.js +26 -22
- package/src/reconciler/actual-state-scanner.js +2 -8
- package/src/reconciler/backup-locations.js +5 -0
- package/src/reconciler/backup-manager.js +19 -11
- package/src/reconciler/desired-state-calculator.js +89 -57
- package/src/reconciler/plan-executor.js +101 -8
- package/src/reconciler/recorded-versions.js +49 -0
- package/src/reconciler/relative-path.js +23 -0
- package/src/uninstallers/hook-uninstaller.js +9 -1
- package/src/uninstallers/skills-uninstaller.js +22 -3
- package/src/utils/available-standards-report.js +25 -4
- package/src/utils/available-standards.js +13 -3
- package/src/utils/build-manifest.js +1 -1
- package/src/utils/commit-message-judge.js +60 -13
- package/src/utils/friction-detector.js +23 -11
- package/src/utils/git-hooks.js +106 -4
- package/src/utils/integration-generator.js +95 -67
- package/src/utils/legacy-hook-migration.js +121 -2
- package/src/utils/open-work-tracking.mjs +105 -16
- package/src/utils/sdd-header.js +16 -4
- package/src/utils/skills-installer.js +2 -1
- package/src/utils/spinner.js +14 -4
- package/src/utils/standard-validator.js +3 -2
- package/standards-registry.json +10 -8
- package/bundled/locales/zh-TW/core/guides/testing-guide.md +0 -2280
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
source:
|
|
2
|
+
source: ../../../../methodologies/guides/tdd-guide.md
|
|
3
3
|
source_version: 1.2.0
|
|
4
4
|
translation_version: 1.2.0
|
|
5
|
-
last_synced: 2026-
|
|
5
|
+
last_synced: 2026-10-16
|
|
6
|
+
source_hash: 15f328d37322
|
|
6
7
|
status: current
|
|
7
8
|
---
|
|
8
9
|
|
|
@@ -13,7 +14,7 @@ status: current
|
|
|
13
14
|
**適用範圍**: 所有採用測試驅動開發的專案
|
|
14
15
|
**範圍**: universal
|
|
15
16
|
|
|
16
|
-
> **語言**: [English](../../../../
|
|
17
|
+
> **語言**: [English](../../../../methodologies/guides/tdd-guide.md) | 繁體中文
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
@@ -34,7 +35,7 @@ status: current
|
|
|
34
35
|
|
|
35
36
|
> **分類**: 傳統開發方法論 (1999-2011)
|
|
36
37
|
|
|
37
|
-
TDD
|
|
38
|
+
TDD 是源自極限編程 (XP) 與敏捷實踐的**傳統測試驅動開發家族**之一部分。它有別於 **AI 時代的 SDD (規格驅動開發)** 方法論。
|
|
38
39
|
|
|
39
40
|
### 歷史背景
|
|
40
41
|
|
|
@@ -51,27 +52,27 @@ TDD 可以**在 SDD 實作階段內**使用,但不是 SDD 方法論本身的
|
|
|
51
52
|
|
|
52
53
|
```
|
|
53
54
|
┌──────────────────────────────────────────────────────────────┐
|
|
54
|
-
│
|
|
55
|
+
│ Methodology Relationship │
|
|
55
56
|
├──────────────────────────────────────────────────────────────┤
|
|
56
57
|
│ │
|
|
57
|
-
│ SDD
|
|
58
|
-
│
|
|
58
|
+
│ SDD Workflow: │
|
|
59
|
+
│ Discuss → Proposal → Review → [Implementation] → Verify │
|
|
59
60
|
│ ↑ │
|
|
60
|
-
│ TDD
|
|
61
|
-
│ (
|
|
61
|
+
│ TDD can be used here │
|
|
62
|
+
│ (optional, not required) │
|
|
62
63
|
│ │
|
|
63
|
-
│
|
|
64
|
-
│ BDD (
|
|
64
|
+
│ Traditional Double-Loop TDD (GOOS): │
|
|
65
|
+
│ BDD (Outer) → TDD (Inner) │
|
|
65
66
|
│ │
|
|
66
|
-
│ SDD
|
|
67
|
-
│ TDD
|
|
67
|
+
│ SDD generates test artifacts through Forward Derivation, │
|
|
68
|
+
│ which TDD can then use as starting point. │
|
|
68
69
|
│ │
|
|
69
70
|
└──────────────────────────────────────────────────────────────┘
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
### 何時使用 TDD
|
|
73
74
|
|
|
74
|
-
|
|
|
75
|
+
| 情境 | 建議 |
|
|
75
76
|
|---------|----------------|
|
|
76
77
|
| **SDD 專案** | 在實作階段使用 TDD (選擇性) |
|
|
77
78
|
| **舊系統專案** | 對新功能和錯誤修復使用 TDD |
|
|
@@ -84,22 +85,22 @@ TDD 可以**在 SDD 實作階段內**使用,但不是 SDD 方法論本身的
|
|
|
84
85
|
|
|
85
86
|
## 目錄
|
|
86
87
|
|
|
87
|
-
1. [TDD 核心循環](#tdd
|
|
88
|
-
2. [TDD 原則](#tdd
|
|
89
|
-
3. [適用場景指南](
|
|
88
|
+
1. [TDD 核心循環](#tdd-core-cycle)
|
|
89
|
+
2. [TDD 原則](#tdd-principles)
|
|
90
|
+
3. [適用場景指南](#applicability-guide)
|
|
90
91
|
4. [TDD vs BDD vs ATDD](#tdd-vs-bdd-vs-atdd)
|
|
91
|
-
5. [與 SDD 整合](
|
|
92
|
-
6. [TDD 工作流程](#tdd
|
|
93
|
-
7. [測試設計指南](
|
|
94
|
-
8. [重構策略](
|
|
95
|
-
9. [TDD 中的測試替身](#tdd
|
|
96
|
-
10. [反模式與修復](
|
|
97
|
-
11. [語言/框架實踐](
|
|
98
|
-
12. [度量與評估](
|
|
99
|
-
13. [相關標準](
|
|
100
|
-
14. [參考資料](
|
|
101
|
-
15. [版本歷史](
|
|
102
|
-
16. [授權](
|
|
92
|
+
5. [與 SDD 整合](#integration-with-sdd)
|
|
93
|
+
6. [TDD 工作流程](#tdd-workflow)
|
|
94
|
+
7. [測試設計指南](#test-design-guidelines)
|
|
95
|
+
8. [重構策略](#refactoring-strategies)
|
|
96
|
+
9. [TDD 中的測試替身](#test-doubles-in-tdd)
|
|
97
|
+
10. [反模式與修復](#anti-patterns-and-remediation)
|
|
98
|
+
11. [語言/框架實踐](#languageframework-practices)
|
|
99
|
+
12. [度量與評估](#metrics-and-assessment)
|
|
100
|
+
13. [相關標準](#related-standards)
|
|
101
|
+
14. [參考資料](#references)
|
|
102
|
+
15. [版本歷史](#version-history)
|
|
103
|
+
16. [授權](#license)
|
|
103
104
|
|
|
104
105
|
---
|
|
105
106
|
|
|
@@ -111,31 +112,31 @@ TDD 遵循一個簡單但強大的迭代循環:
|
|
|
111
112
|
|
|
112
113
|
```
|
|
113
114
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
114
|
-
│ TDD
|
|
115
|
+
│ TDD Core Cycle │
|
|
115
116
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
116
117
|
│ │
|
|
117
118
|
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
118
|
-
│ │ 🔴
|
|
119
|
+
│ │ 🔴 RED │────────▶│ 🟢 GREEN│────────▶│🔵 REFACTOR│ │
|
|
119
120
|
│ └─────────┘ └─────────┘ └─────────┘ │
|
|
120
121
|
│ ▲ │ │
|
|
121
122
|
│ │ │ │
|
|
122
123
|
│ └────────────────────────────────────────┘ │
|
|
123
124
|
│ │
|
|
124
|
-
│ 🔴
|
|
125
|
-
│ ├─
|
|
126
|
-
│ ├─
|
|
127
|
-
│ └─
|
|
125
|
+
│ 🔴 RED Phase (1-5 minutes) │
|
|
126
|
+
│ ├─ Write a failing test that describes expected behavior │
|
|
127
|
+
│ ├─ Test should fail for the RIGHT reason │
|
|
128
|
+
│ └─ Verify the test actually fails │
|
|
128
129
|
│ │
|
|
129
|
-
│ 🟢
|
|
130
|
-
│ ├─
|
|
131
|
-
│ ├─
|
|
132
|
-
│ └─
|
|
130
|
+
│ 🟢 GREEN Phase (1-10 minutes) │
|
|
131
|
+
│ ├─ Write the MINIMUM code to make the test pass │
|
|
132
|
+
│ ├─ "Fake it till you make it" is acceptable │
|
|
133
|
+
│ └─ Don't over-engineer; just make it work │
|
|
133
134
|
│ │
|
|
134
|
-
│ 🔵
|
|
135
|
-
│ ├─
|
|
136
|
-
│ ├─
|
|
137
|
-
│ ├─
|
|
138
|
-
│ └─
|
|
135
|
+
│ 🔵 REFACTOR Phase (5-15 minutes) │
|
|
136
|
+
│ ├─ Improve code quality while keeping tests green │
|
|
137
|
+
│ ├─ Remove duplication (DRY) │
|
|
138
|
+
│ ├─ Improve naming, structure, readability │
|
|
139
|
+
│ └─ Run tests after each refactoring step │
|
|
139
140
|
│ │
|
|
140
141
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
141
142
|
```
|
|
@@ -143,16 +144,16 @@ TDD 遵循一個簡單但強大的迭代循環:
|
|
|
143
144
|
### 循環時間建議
|
|
144
145
|
|
|
145
146
|
| 階段 | 建議時間 | 警示訊號 |
|
|
146
|
-
|
|
147
|
-
| 🔴
|
|
148
|
-
| 🟢
|
|
149
|
-
| 🔵
|
|
147
|
+
|-------|-----------------|---------------|
|
|
148
|
+
| 🔴 RED | 1-5 分鐘 | 若 >10 分鐘,測試範圍太大 |
|
|
149
|
+
| 🟢 GREEN | 1-10 分鐘 | 若 >15 分鐘,需要拆解問題 |
|
|
150
|
+
| 🔵 REFACTOR | 5-15 分鐘 | 若跳過,技術債會累積 |
|
|
150
151
|
|
|
151
152
|
### 口訣
|
|
152
153
|
|
|
153
|
-
>
|
|
154
|
+
> **Red → Green → Refactor → Repeat**
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
每次迭代都應該很小。如果你發現自己在任何階段花費太長時間,該測試可能設定得過於龐大。
|
|
156
157
|
|
|
157
158
|
---
|
|
158
159
|
|
|
@@ -163,43 +164,43 @@ TDD 遵循一個簡單但強大的迭代循環:
|
|
|
163
164
|
高品質的測試遵循 FIRST 原則:
|
|
164
165
|
|
|
165
166
|
| 原則 | 說明 | 實踐指南 |
|
|
166
|
-
|
|
167
|
-
| **F**ast
|
|
168
|
-
| **I**ndependent
|
|
169
|
-
| **R**epeatable
|
|
170
|
-
| **S**elf-validating
|
|
171
|
-
| **T**imely
|
|
167
|
+
|-----------|-------------|---------------------|
|
|
168
|
+
| **F**ast | 測試應該快速執行 | 單元測試每個 < 100ms;總測試套件 < 10s |
|
|
169
|
+
| **I**ndependent | 測試之間不互相依賴 | 無共用狀態;每個測試自行設定其資料 |
|
|
170
|
+
| **R**epeatable | 每次執行結果相同 | 無隨機性;無時間依賴;無外部 I/O |
|
|
171
|
+
| **S**elf-validating | 明確的通過/失敗結果 | 不需手動檢查;明確的斷言 |
|
|
172
|
+
| **T**imely | 在生產程式碼之前撰寫 | 這是 TDD 的本質 |
|
|
172
173
|
|
|
173
|
-
### Uncle Bob 的 TDD
|
|
174
|
+
### Uncle Bob 的 TDD 三項規則
|
|
174
175
|
|
|
175
176
|
Robert C. Martin (Uncle Bob) 用三條嚴格的規則定義 TDD:
|
|
176
177
|
|
|
177
178
|
1. **規則一(紅色規則)**:除非是為了讓失敗的單元測試通過,否則不允許撰寫任何生產程式碼。
|
|
178
179
|
|
|
179
|
-
2.
|
|
180
|
+
2. **規則二(測試規則)**:不允許撰寫超過足以失敗程度的單元測試;編譯失敗也算失敗。
|
|
180
181
|
|
|
181
|
-
3.
|
|
182
|
+
3. **規則三(綠色規則)**:不允許撰寫超過足以讓單一失敗單元測試通過程度的生產程式碼。
|
|
182
183
|
|
|
183
184
|
### 測試的單一職責
|
|
184
185
|
|
|
185
186
|
每個測試應該驗證「一個」行為:
|
|
186
187
|
|
|
187
188
|
```
|
|
188
|
-
✅
|
|
189
|
-
❌
|
|
189
|
+
✅ Good: test_calculate_total_with_discount_applies_percentage()
|
|
190
|
+
❌ Bad: test_calculate_total_and_tax_and_discount_and_shipping()
|
|
190
191
|
```
|
|
191
192
|
|
|
192
193
|
### 測試即文件
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
撰寫良好的測試可作為可執行的文件:
|
|
195
196
|
|
|
196
197
|
```
|
|
197
|
-
✅
|
|
198
|
+
✅ Good test names:
|
|
198
199
|
- should_return_empty_list_when_no_users_found
|
|
199
200
|
- should_throw_validation_error_when_email_is_invalid
|
|
200
201
|
- should_calculate_discount_when_order_exceeds_threshold
|
|
201
202
|
|
|
202
|
-
❌
|
|
203
|
+
❌ Bad test names:
|
|
203
204
|
- test1
|
|
204
205
|
- testCalculate
|
|
205
206
|
- itWorks
|
|
@@ -209,95 +210,95 @@ Robert C. Martin (Uncle Bob) 用三條嚴格的規則定義 TDD:
|
|
|
209
210
|
|
|
210
211
|
## 適用場景指南
|
|
211
212
|
|
|
212
|
-
### TDD
|
|
213
|
+
### 依情境劃分的 TDD 適用性
|
|
213
214
|
|
|
214
|
-
|
|
|
215
|
+
| 情境 | 評級 | 附註 |
|
|
215
216
|
|------|------|------|
|
|
216
|
-
| **新功能開發** | ⭐⭐⭐⭐⭐ | TDD
|
|
217
|
-
| **Bug 修復** | ⭐⭐⭐⭐⭐ |
|
|
218
|
-
| **API 設計** | ⭐⭐⭐⭐⭐ |
|
|
219
|
-
| **核心業務邏輯** | ⭐⭐⭐⭐⭐ |
|
|
220
|
-
|
|
|
221
|
-
|
|
|
222
|
-
| **UI
|
|
223
|
-
| **探索性原型** | ⭐⭐ | TDD
|
|
224
|
-
|
|
|
217
|
+
| **新功能開發** | ⭐⭐⭐⭐⭐ | TDD 最佳使用案例;設計從測試中浮現 |
|
|
218
|
+
| **Bug 修復** | ⭐⭐⭐⭐⭐ | 先撰寫失敗測試以重現 bug |
|
|
219
|
+
| **API 設計** | ⭐⭐⭐⭐⭐ | 測試可作為 API 使用文件 |
|
|
220
|
+
| **核心業務邏輯** | ⭐⭐⭐⭐⭐ | 高價值程式碼必須具備測試保護 |
|
|
221
|
+
| **演算法實作** | ⭐⭐⭐⭐ | 邊界情況繁多;TDD 有助於全面思考 |
|
|
222
|
+
| **重構既有程式碼** | ⭐⭐⭐⭐ | 先補足測試,再安全地重構 |
|
|
223
|
+
| **UI 元件** | ⭐⭐⭐ | 部分適用;可與 BDD 結合 |
|
|
224
|
+
| **探索性原型** | ⭐⭐ | TDD 可能會拖慢充滿不確定性的探索 |
|
|
225
|
+
| **一次性指令碼** | ⭐ | 成本效益比低 |
|
|
225
226
|
| **第三方整合** | ⭐⭐ | 難以 Mock;改用整合測試 |
|
|
226
227
|
|
|
227
228
|
### 依專案類型的 TDD
|
|
228
229
|
|
|
229
230
|
| 專案類型 | TDD | BDD | ATDD | 建議 |
|
|
230
|
-
|
|
231
|
-
| **新創 MVP** | ⚠️ 選擇性 | ✅
|
|
232
|
-
|
|
|
233
|
-
| **開源專案** | ✅
|
|
234
|
-
|
|
|
235
|
-
| **微服務** | ✅
|
|
231
|
+
|----------|-----|-----|------|------|
|
|
232
|
+
| **新創 MVP** | ⚠️ 選擇性 | ✅ 建議 | ❌ | 優先考量快速迭代 |
|
|
233
|
+
| **企業級應用程式** | ✅ 建議 | ✅ 建議 | ✅ 建議 | 品質與可維護性極為關鍵 |
|
|
234
|
+
| **開源專案** | ✅ 建議 | ⚠️ 選擇性 | ❌ | 貢獻者需要測試文件 |
|
|
235
|
+
| **老舊系統改造** | ✅ 必須 | ⚠️ 選擇性 | ❌ | 使用 Golden Master 策略(見下方) |
|
|
236
|
+
| **微服務** | ✅ 建議 | ✅ 建議 | ✅ 建議 | 合約測試至關重要 |
|
|
236
237
|
| **資料管線** | ⚠️ 選擇性 | ❌ | ❌ | 以整合測試為主 |
|
|
237
|
-
| **機器學習** | 🔶 視情況 | ❌ | ❌ |
|
|
238
|
+
| **機器學習** | 🔶 視情況 | ❌ | ❌ | 請參閱下方的 ML 測試邊界 |
|
|
238
239
|
|
|
239
240
|
### 機器學習 (ML) 測試邊界
|
|
240
241
|
|
|
241
|
-
|
|
242
|
+
**重要提示**:ML 專案需要區分「模型效能」與「資料工程」:
|
|
242
243
|
|
|
243
244
|
| 面向 | TDD 適用性 | 說明 |
|
|
244
245
|
|------|-----------|------|
|
|
245
|
-
|
|
|
246
|
-
|
|
|
247
|
-
|
|
|
248
|
-
| **資料轉換** | ✅ 必須 |
|
|
246
|
+
| **模型準確度** | ❌ 不適用 | 結果具非確定性;難以預先定義預期結果 |
|
|
247
|
+
| **特徵工程** | ✅ 必須 | 避免 Garbage In, Garbage Out |
|
|
248
|
+
| **資料清理** | ✅ 必須 | 資料品質會直接影響模型效能 |
|
|
249
|
+
| **資料轉換** | ✅ 必須 | 確保轉換邏輯正確無誤 |
|
|
249
250
|
| **管線整合** | ⚠️ 選擇性 | 以整合測試為主 |
|
|
250
251
|
|
|
251
|
-
###
|
|
252
|
+
### 老舊系統策略:Golden Master 測試
|
|
252
253
|
|
|
253
|
-
|
|
254
|
+
**問題**:在沒有測試的老舊系統中,「新增測試」本身就伴隨著破壞既有邏輯的風險。
|
|
254
255
|
|
|
255
|
-
**Golden Master
|
|
256
|
+
**Golden Master 測試工作流程**:
|
|
256
257
|
|
|
257
258
|
```
|
|
258
259
|
┌─────────────────────────────────────────────────────────────────┐
|
|
259
|
-
│ Golden Master Testing
|
|
260
|
+
│ Golden Master Testing Workflow │
|
|
260
261
|
├─────────────────────────────────────────────────────────────────┤
|
|
261
262
|
│ │
|
|
262
|
-
│ 1️⃣
|
|
263
|
-
│ ├─
|
|
264
|
-
│ ├─
|
|
265
|
-
│ └─
|
|
263
|
+
│ 1️⃣ RECORD Phase (Don't modify code) │
|
|
264
|
+
│ ├─ Execute system with many inputs │
|
|
265
|
+
│ ├─ Record all outputs as "golden baseline" │
|
|
266
|
+
│ └─ Use automation tools or AI to generate test cases │
|
|
266
267
|
│ │
|
|
267
|
-
│ 2️⃣
|
|
268
|
-
│ ├─
|
|
269
|
-
│ └─
|
|
268
|
+
│ 2️⃣ VERIFY Phase │
|
|
269
|
+
│ ├─ Create Snapshot/Approval tests │
|
|
270
|
+
│ └─ Ensure pre/post refactoring outputs match │
|
|
270
271
|
│ │
|
|
271
|
-
│ 3️⃣
|
|
272
|
-
│ ├─
|
|
273
|
-
│ ├─
|
|
274
|
-
│ └─
|
|
272
|
+
│ 3️⃣ REFACTOR Phase │
|
|
273
|
+
│ ├─ Safely refactor under Golden Master protection │
|
|
274
|
+
│ ├─ Run Golden Master tests after each modification │
|
|
275
|
+
│ └─ Gradually convert Golden Masters to proper unit tests │
|
|
275
276
|
│ │
|
|
276
|
-
│ 4️⃣
|
|
277
|
-
│ └─
|
|
277
|
+
│ 4️⃣ EVOLVE Phase │
|
|
278
|
+
│ └─ New features use standard TDD │
|
|
278
279
|
│ │
|
|
279
280
|
└─────────────────────────────────────────────────────────────────┘
|
|
280
281
|
```
|
|
281
282
|
|
|
282
283
|
**工具支援**:
|
|
283
|
-
- ApprovalTests
|
|
284
|
-
- Jest Snapshot Testing
|
|
285
|
-
- Python
|
|
286
|
-
- AI
|
|
284
|
+
- ApprovalTests(支援多種語言)
|
|
285
|
+
- Jest 快照測試(Jest Snapshot Testing)
|
|
286
|
+
- Python:pytest-snapshot
|
|
287
|
+
- AI 輔助的測試輸入生成
|
|
287
288
|
|
|
288
289
|
### 決策樹
|
|
289
290
|
|
|
290
291
|
```
|
|
291
|
-
|
|
292
|
-
├─
|
|
293
|
-
├─
|
|
294
|
-
│ ├─
|
|
295
|
-
│ │ ├─
|
|
296
|
-
│ │ └─
|
|
297
|
-
│ └─
|
|
298
|
-
│ ├─
|
|
299
|
-
│ └─
|
|
300
|
-
└─
|
|
292
|
+
Requirement Source?
|
|
293
|
+
├─ Technical (performance, refactoring) → TDD
|
|
294
|
+
├─ Business Requirement
|
|
295
|
+
│ ├─ Has clear acceptance criteria?
|
|
296
|
+
│ │ ├─ Yes → ATDD → BDD → TDD
|
|
297
|
+
│ │ └─ No → BDD → TDD
|
|
298
|
+
│ └─ Complex business flow?
|
|
299
|
+
│ ├─ Yes → BDD (scenario description) → TDD
|
|
300
|
+
│ └─ No → TDD
|
|
301
|
+
└─ Exploratory/Prototype → Skip TDD temporarily
|
|
301
302
|
```
|
|
302
303
|
|
|
303
304
|
---
|
|
@@ -308,101 +309,114 @@ Robert C. Martin (Uncle Bob) 用三條嚴格的規則定義 TDD:
|
|
|
308
309
|
|
|
309
310
|
| 面向 | TDD | BDD | ATDD |
|
|
310
311
|
|------|-----|-----|------|
|
|
311
|
-
| **焦點** | 程式碼單元 | 行為 |
|
|
312
|
+
| **焦點** | 程式碼單元 | 行為 | 驗收條件 |
|
|
312
313
|
| **語言** | 程式碼 | 自然語言 (Gherkin) | 業務語言 |
|
|
313
|
-
| **參與者** |
|
|
314
|
-
| **測試層級** |
|
|
315
|
-
| **工具** | xUnit 框架 | Cucumber
|
|
316
|
-
| **時機** |
|
|
314
|
+
| **參與者** | 開發人員 | 開發人員 + 業務分析師 (BA) + 品質工程師 (QA) | 全體團隊 + 利害關係人 |
|
|
315
|
+
| **測試層級** | 單元/整合 | 功能/場景 | 系統/驗收 |
|
|
316
|
+
| **工具** | xUnit 框架 | Cucumber、Behave、SpecFlow | FitNesse、Concordion |
|
|
317
|
+
| **時機** | 編寫程式碼期間 | 編寫程式碼之前 | 開發開始之前 |
|
|
317
318
|
|
|
318
|
-
###
|
|
319
|
+
### 雙循環 TDD (GOOS 模式)
|
|
319
320
|
|
|
320
321
|
```
|
|
321
322
|
┌─────────────────────────────────────────────────────────────────┐
|
|
322
|
-
│
|
|
323
|
+
│ Double-Loop TDD (Freeman & Pryce, 2009) │
|
|
323
324
|
├─────────────────────────────────────────────────────────────────┤
|
|
324
325
|
│ │
|
|
325
|
-
│
|
|
326
|
-
│
|
|
327
|
-
│
|
|
328
|
-
│
|
|
329
|
-
│
|
|
330
|
-
│
|
|
331
|
-
│
|
|
332
|
-
│
|
|
333
|
-
│
|
|
334
|
-
│
|
|
335
|
-
│
|
|
336
|
-
│
|
|
337
|
-
│
|
|
326
|
+
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
327
|
+
│ │ BDD (Outer Loop) - Hours to Days │ │
|
|
328
|
+
│ │ ├─ Feature/Acceptance level │ │
|
|
329
|
+
│ │ ├─ User/Business perspective │ │
|
|
330
|
+
│ │ └─ Given-When-Then scenarios │ │
|
|
331
|
+
│ │ ↓ │ │
|
|
332
|
+
│ │ ┌─────────────────────────────────────────────────┐ │ │
|
|
333
|
+
│ │ │ TDD (Inner Loop) - Minutes │ │ │
|
|
334
|
+
│ │ │ ├─ Unit/Component level │ │ │
|
|
335
|
+
│ │ │ ├─ Code/Implementation perspective │ │ │
|
|
336
|
+
│ │ │ └─ Red → Green → Refactor │ │ │
|
|
337
|
+
│ │ └─────────────────────────────────────────────────┘ │ │
|
|
338
|
+
│ └─────────────────────────────────────────────────────────┘ │
|
|
338
339
|
│ │
|
|
339
|
-
│
|
|
340
|
+
│ Key: BDD → TDD (Double-Loop from GOOS) │
|
|
341
|
+
│ │
|
|
342
|
+
│ Note: ATDD is an optional collaboration method for defining │
|
|
343
|
+
│ acceptance criteria, not a required step in this sequence. │
|
|
344
|
+
│ SDD (2025) is a separate AI-era methodology. │
|
|
340
345
|
│ │
|
|
341
346
|
└─────────────────────────────────────────────────────────────────┘
|
|
342
347
|
```
|
|
343
348
|
|
|
349
|
+
### 傳統與 AI 時代方法論
|
|
350
|
+
|
|
351
|
+
| 類別 | 方法論 | 焦點 |
|
|
352
|
+
|------|--------|------|
|
|
353
|
+
| **傳統 (1999-2011)** | TDD、BDD、ATDD | 測試驅動設計 |
|
|
354
|
+
| **AI 時代 (2025+)** | SDD | 規格驅動生成 |
|
|
355
|
+
|
|
356
|
+
> **附註**:SDD 可在其實作階段使用 TDD,但兩者是獨立的方法論。詳情請參閱 [規格驅動開發](../../core/spec-driven-development.md)。
|
|
357
|
+
|
|
344
358
|
### BDD Gherkin 語法概覽
|
|
345
359
|
|
|
346
360
|
```gherkin
|
|
347
|
-
Feature:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
Scenario:
|
|
353
|
-
Given
|
|
354
|
-
And
|
|
355
|
-
When
|
|
356
|
-
And
|
|
357
|
-
And
|
|
358
|
-
Then
|
|
359
|
-
And
|
|
360
|
-
|
|
361
|
-
Scenario:
|
|
362
|
-
Given
|
|
363
|
-
When
|
|
364
|
-
And
|
|
365
|
-
And
|
|
366
|
-
Then
|
|
367
|
-
And
|
|
361
|
+
Feature: User Login
|
|
362
|
+
As a registered user
|
|
363
|
+
I want to log into my account
|
|
364
|
+
So that I can access my personalized content
|
|
365
|
+
|
|
366
|
+
Scenario: Successful login with valid credentials
|
|
367
|
+
Given I am on the login page
|
|
368
|
+
And I have a registered account with email "user@example.com"
|
|
369
|
+
When I enter email "user@example.com"
|
|
370
|
+
And I enter password "correctpassword"
|
|
371
|
+
And I click the login button
|
|
372
|
+
Then I should be redirected to the dashboard
|
|
373
|
+
And I should see a welcome message with my name
|
|
374
|
+
|
|
375
|
+
Scenario: Failed login with invalid password
|
|
376
|
+
Given I am on the login page
|
|
377
|
+
When I enter email "user@example.com"
|
|
378
|
+
And I enter password "wrongpassword"
|
|
379
|
+
And I click the login button
|
|
380
|
+
Then I should see an error message "Invalid credentials"
|
|
381
|
+
And I should remain on the login page
|
|
368
382
|
```
|
|
369
383
|
|
|
370
|
-
### ATDD
|
|
384
|
+
### ATDD 驗收條件格式
|
|
371
385
|
|
|
372
386
|
```markdown
|
|
373
|
-
##
|
|
387
|
+
## Feature: Shopping Cart Checkout
|
|
374
388
|
|
|
375
|
-
###
|
|
389
|
+
### Acceptance Criteria:
|
|
376
390
|
|
|
377
|
-
**AC-1
|
|
378
|
-
- GIVEN
|
|
379
|
-
- WHEN
|
|
380
|
-
- THEN
|
|
391
|
+
**AC-1: Calculate Order Total**
|
|
392
|
+
- GIVEN items in cart with prices [$10, $20, $15]
|
|
393
|
+
- WHEN user proceeds to checkout
|
|
394
|
+
- THEN total should be $45
|
|
381
395
|
|
|
382
|
-
**AC-2
|
|
383
|
-
- GIVEN
|
|
384
|
-
- AND
|
|
385
|
-
- WHEN
|
|
386
|
-
- THEN
|
|
396
|
+
**AC-2: Apply Discount Code**
|
|
397
|
+
- GIVEN cart total is $100
|
|
398
|
+
- AND valid discount code "SAVE20" for 20% off
|
|
399
|
+
- WHEN user applies discount code
|
|
400
|
+
- THEN total should be $80
|
|
387
401
|
|
|
388
|
-
**AC-3
|
|
389
|
-
- GIVEN
|
|
390
|
-
- WHEN
|
|
391
|
-
- THEN
|
|
402
|
+
**AC-3: Validate Minimum Order**
|
|
403
|
+
- GIVEN cart total is below $25
|
|
404
|
+
- WHEN user attempts checkout
|
|
405
|
+
- THEN system should show "Minimum order is $25" error
|
|
392
406
|
```
|
|
393
407
|
|
|
394
|
-
###
|
|
408
|
+
### 選擇適當的做法
|
|
395
409
|
|
|
396
|
-
| 使用案例 |
|
|
397
|
-
|
|
398
|
-
|
|
|
410
|
+
| 使用案例 | 主要做法 | 輔助做法 |
|
|
411
|
+
|----------|----------|----------|
|
|
412
|
+
| 演算法實作 | TDD | - |
|
|
399
413
|
| 使用者驗證流程 | BDD | TDD |
|
|
400
|
-
|
|
|
401
|
-
| API 端點 | TDD | BDD
|
|
402
|
-
| UI
|
|
414
|
+
| 付款處理 | ATDD | BDD + TDD |
|
|
415
|
+
| API 端點 | TDD | BDD(用於整合) |
|
|
416
|
+
| UI 元件 | BDD | TDD(用於邏輯) |
|
|
403
417
|
| 業務規則驗證 | ATDD | TDD |
|
|
404
|
-
|
|
|
405
|
-
| 外部服務整合 | TDD | BDD
|
|
418
|
+
| 效能最佳化 | TDD | - |
|
|
419
|
+
| 外部服務整合 | TDD | BDD(用於合約) |
|
|
406
420
|
|
|
407
421
|
---
|
|
408
422
|
|
|
@@ -417,66 +431,66 @@ Feature: 使用者登入
|
|
|
417
431
|
|
|
418
432
|
```
|
|
419
433
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
420
|
-
│ SDD + TDD 整合工作流程
|
|
434
|
+
│ SDD + TDD 整合工作流程 │
|
|
421
435
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
422
436
|
│ │
|
|
423
|
-
│ 1️⃣ SDD
|
|
424
|
-
│ ├─ 撰寫 Spec
|
|
425
|
-
│ ├─
|
|
426
|
-
│ └─
|
|
437
|
+
│ 1️⃣ SDD: PROPOSAL 階段 │
|
|
438
|
+
│ ├─ 撰寫 Spec:定義功能、驗收條件、邊界情況 │
|
|
439
|
+
│ ├─ 包含驗收條件(轉換為 ATDD 場景) │
|
|
440
|
+
│ └─ 取得利益相關者核准 │
|
|
427
441
|
│ (Spec ID: SPEC-001) │
|
|
428
442
|
│ │
|
|
429
|
-
│ 2️⃣ TDD
|
|
430
|
-
│ ├─
|
|
443
|
+
│ 2️⃣ TDD: RED 階段 │
|
|
444
|
+
│ ├─ 根據 Spec 的驗收條件撰寫測試 │
|
|
431
445
|
│ ├─ 撰寫描述預期行為的失敗測試 │
|
|
432
|
-
│ ├─
|
|
433
|
-
│ └─
|
|
446
|
+
│ ├─ 測試實作 Spec:一個條件 = 多個測試 │
|
|
447
|
+
│ └─ 在測試檔案註釋中引用 SPEC-001 │
|
|
434
448
|
│ │
|
|
435
|
-
│ 3️⃣ TDD
|
|
436
|
-
│ ├─
|
|
437
|
-
│ ├─
|
|
438
|
-
│ └─ 保持所有 Spec
|
|
449
|
+
│ 3️⃣ TDD: GREEN + REFACTOR 階段 │
|
|
450
|
+
│ ├─ 迭代開發,一次實作一個小功能 │
|
|
451
|
+
│ ├─ 測試通過後進行重構 │
|
|
452
|
+
│ └─ 保持所有 Spec 驗收條件測試處於通過狀態 │
|
|
439
453
|
│ │
|
|
440
|
-
│ 4️⃣ SDD
|
|
441
|
-
│ ├─
|
|
454
|
+
│ 4️⃣ SDD: VERIFICATION 階段 │
|
|
455
|
+
│ ├─ 確認實作符合 Spec │
|
|
442
456
|
│ ├─ 驗收測試套件通過 │
|
|
443
|
-
│ └─
|
|
457
|
+
│ └─ 所有驗收條件均已實作 ✓ │
|
|
444
458
|
│ │
|
|
445
|
-
│ 5️⃣ 提交 PR
|
|
459
|
+
│ 5️⃣ 提交 PR 並撰寫 Commit 訊息 │
|
|
446
460
|
│ ├─ Commit: "feat(auth): implement login" │
|
|
447
|
-
│ ├─
|
|
448
|
-
│ ├─
|
|
461
|
+
│ ├─ 內文: "Implements SPEC-001 with OAuth2" │
|
|
462
|
+
│ ├─ 引用: SPEC-001 │
|
|
449
463
|
│ └─ 包含測試覆蓋率報告 │
|
|
450
464
|
│ │
|
|
451
|
-
│ 6️⃣ SDD
|
|
452
|
-
│ └─
|
|
465
|
+
│ 6️⃣ SDD: ARCHIVE 階段 │
|
|
466
|
+
│ └─ 封存 Spec,連結至 PR/commits │
|
|
453
467
|
│ │
|
|
454
468
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
455
469
|
```
|
|
456
470
|
|
|
457
|
-
### 將 Spec
|
|
471
|
+
### 將 Spec 驗收條件對應至 TDD 測試
|
|
458
472
|
|
|
459
|
-
| Spec
|
|
460
|
-
|
|
461
|
-
|
|
|
462
|
-
|
|
|
463
|
-
|
|
|
464
|
-
|
|
|
473
|
+
| Spec 驗收條件 | TDD 測試 |
|
|
474
|
+
|---------------|----------|
|
|
475
|
+
| "User can login with valid credentials" | `test_login_with_valid_credentials_succeeds()` |
|
|
476
|
+
| "Invalid password shows error" | `test_login_with_invalid_password_shows_error()` |
|
|
477
|
+
| "Account locked after 3 failed attempts" | `test_account_locks_after_three_failed_attempts()` |
|
|
478
|
+
| "Locked account cannot login" | `test_locked_account_cannot_login()` |
|
|
465
479
|
|
|
466
|
-
###
|
|
480
|
+
### 在測試中引用 Spec
|
|
467
481
|
|
|
468
482
|
```typescript
|
|
469
483
|
/**
|
|
470
|
-
* SPEC-001
|
|
484
|
+
* Tests for SPEC-001: User Authentication
|
|
471
485
|
* @see specs/SPEC-001-user-authentication.md
|
|
472
486
|
*/
|
|
473
|
-
describe('
|
|
474
|
-
// AC-1
|
|
487
|
+
describe('User Authentication (SPEC-001)', () => {
|
|
488
|
+
// AC-1: User can login with valid credentials
|
|
475
489
|
test('should login successfully with valid credentials', async () => {
|
|
476
490
|
// ...
|
|
477
491
|
});
|
|
478
492
|
|
|
479
|
-
// AC-2
|
|
493
|
+
// AC-2: Invalid password shows error
|
|
480
494
|
test('should show error message for invalid password', async () => {
|
|
481
495
|
// ...
|
|
482
496
|
});
|
|
@@ -491,71 +505,71 @@ describe('使用者驗證 (SPEC-001)', () => {
|
|
|
491
505
|
|
|
492
506
|
```
|
|
493
507
|
┌─────────────────────────────────────────────────────────────────┐
|
|
494
|
-
│ 個人 TDD 工作階段流程
|
|
508
|
+
│ 個人 TDD 工作階段流程 │
|
|
495
509
|
├─────────────────────────────────────────────────────────────────┤
|
|
496
510
|
│ │
|
|
497
|
-
│ 1. 理解需求
|
|
498
|
-
│ ├─
|
|
499
|
-
│ └─
|
|
511
|
+
│ 1. 理解需求 │
|
|
512
|
+
│ ├─ 閱讀規格/使用者故事 │
|
|
513
|
+
│ └─ 識別驗收條件 │
|
|
500
514
|
│ │
|
|
501
|
-
│ 2.
|
|
502
|
-
│ ├─
|
|
503
|
-
│ ├─ 邊界情況
|
|
504
|
-
│ ├─ 錯誤場景
|
|
505
|
-
│ └─ 邊界條件
|
|
515
|
+
│ 2. 列出測試案例(在紙上或 TODO 註釋中) │
|
|
516
|
+
│ ├─ 正常路徑(Happy path)場景 │
|
|
517
|
+
│ ├─ 邊界情況 │
|
|
518
|
+
│ ├─ 錯誤場景 │
|
|
519
|
+
│ └─ 邊界條件 │
|
|
506
520
|
│ │
|
|
507
|
-
│ 3.
|
|
508
|
-
│ └─
|
|
521
|
+
│ 3. 挑選最簡單的測試案例 │
|
|
522
|
+
│ └─ 從最基本的正常路徑開始 │
|
|
509
523
|
│ │
|
|
510
|
-
│ 4.
|
|
511
|
-
│ ├─
|
|
512
|
-
│ ├─
|
|
513
|
-
│ └─
|
|
524
|
+
│ 4. RED:撰寫測試 │
|
|
525
|
+
│ ├─ 撰寫具有清晰 Arrange-Act-Assert 的測試 │
|
|
526
|
+
│ ├─ 使用具描述性的測試名稱 │
|
|
527
|
+
│ └─ 執行測試,驗證其失敗 │
|
|
514
528
|
│ │
|
|
515
|
-
│ 5.
|
|
516
|
-
│ ├─
|
|
517
|
-
│ ├─
|
|
518
|
-
│ └─
|
|
529
|
+
│ 5. GREEN:讓測試通過 │
|
|
530
|
+
│ ├─ 撰寫最少量的程式碼使其通過 │
|
|
531
|
+
│ ├─ 「先假裝,再實現」是可以接受的 │
|
|
532
|
+
│ └─ 執行測試,驗證其通過 │
|
|
519
533
|
│ │
|
|
520
|
-
│ 6.
|
|
521
|
-
│ ├─ 消除重複
|
|
522
|
-
│ ├─ 改善命名
|
|
523
|
-
│ ├─
|
|
524
|
-
│ └─ 每次變更後執行所有測試
|
|
534
|
+
│ 6. REFACTOR:清理程式碼 │
|
|
535
|
+
│ ├─ 消除重複 │
|
|
536
|
+
│ ├─ 改善命名 │
|
|
537
|
+
│ ├─ 擷取方法/函式 │
|
|
538
|
+
│ └─ 每次變更後執行所有測試 │
|
|
525
539
|
│ │
|
|
526
|
-
│ 7. 從步驟 3 重複,直到所有測試完成
|
|
540
|
+
│ 7. 從步驟 3 重複,直到所有測試完成 │
|
|
527
541
|
│ │
|
|
528
542
|
└─────────────────────────────────────────────────────────────────┘
|
|
529
543
|
```
|
|
530
544
|
|
|
531
545
|
### 團隊層級 TDD
|
|
532
546
|
|
|
533
|
-
####
|
|
547
|
+
#### 結對編程與 TDD
|
|
534
548
|
|
|
535
|
-
|
|
549
|
+
**乒乓模式(Ping-Pong Pattern)**:
|
|
536
550
|
1. 開發者 A 撰寫一個失敗的測試
|
|
537
|
-
2. 開發者 B
|
|
551
|
+
2. 開發者 B 撰寫程式碼使測試通過
|
|
538
552
|
3. 開發者 B 撰寫下一個失敗的測試
|
|
539
|
-
4. 開發者 A
|
|
540
|
-
5.
|
|
541
|
-
6.
|
|
553
|
+
4. 開發者 A 撰寫程式碼使測試通過
|
|
554
|
+
5. 任一開發者均可在任何時間進行重構
|
|
555
|
+
6. 重複此過程
|
|
542
556
|
|
|
543
|
-
|
|
544
|
-
1.
|
|
545
|
-
2.
|
|
546
|
-
3. 每 15-30
|
|
557
|
+
**駕駛與領航員模式(Driver-Navigator Pattern)**:
|
|
558
|
+
1. 領航員(Navigator)思考設計與測試案例
|
|
559
|
+
2. 駕駛(Driver)撰寫測試與程式碼
|
|
560
|
+
3. 每 15-30 分鐘輪換角色
|
|
547
561
|
|
|
548
|
-
####
|
|
562
|
+
#### 群體編程(Mob Programming)與 TDD
|
|
549
563
|
|
|
550
|
-
-
|
|
551
|
-
- 每 5-10
|
|
552
|
-
-
|
|
553
|
-
-
|
|
564
|
+
- 一位駕駛(鍵盤輸入),多位領航員(引導方向)
|
|
565
|
+
- 每 5-10 分鐘輪換一次駕駛
|
|
566
|
+
- 共同決定測試案例與實作方式
|
|
567
|
+
- 透過多元觀點獲得更高品質
|
|
554
568
|
|
|
555
569
|
### CI/CD 整合
|
|
556
570
|
|
|
557
571
|
```yaml
|
|
558
|
-
#
|
|
572
|
+
# Example GitHub Actions workflow for TDD
|
|
559
573
|
name: TDD CI Pipeline
|
|
560
574
|
|
|
561
575
|
on: [push, pull_request]
|
|
@@ -595,15 +609,15 @@ jobs:
|
|
|
595
609
|
|
|
596
610
|
```typescript
|
|
597
611
|
test('should calculate total with discount', () => {
|
|
598
|
-
// Arrange -
|
|
612
|
+
// Arrange - Set up test data and dependencies
|
|
599
613
|
const cart = new ShoppingCart();
|
|
600
614
|
cart.addItem({ name: 'Widget', price: 100 });
|
|
601
|
-
cart.setDiscountCode('SAVE20'); // 20%
|
|
615
|
+
cart.setDiscountCode('SAVE20'); // 20% discount
|
|
602
616
|
|
|
603
|
-
// Act -
|
|
617
|
+
// Act - Execute the behavior being tested
|
|
604
618
|
const total = cart.calculateTotal();
|
|
605
619
|
|
|
606
|
-
// Assert -
|
|
620
|
+
// Assert - Verify the result
|
|
607
621
|
expect(total).toBe(80);
|
|
608
622
|
});
|
|
609
623
|
```
|
|
@@ -629,35 +643,35 @@ test('given a cart with items, when discount applied, then total is reduced', ()
|
|
|
629
643
|
|
|
630
644
|
| 模式 | 範例 |
|
|
631
645
|
|------|------|
|
|
632
|
-
| `should_[
|
|
633
|
-
| `[
|
|
634
|
-
| `test_[
|
|
635
|
-
| `it_[
|
|
646
|
+
| `should_[behavior]_when_[condition]` | `should_return_error_when_email_invalid` |
|
|
647
|
+
| `[method]_[scenario]_[expected]` | `calculateTotal_withDiscount_returnsReducedPrice` |
|
|
648
|
+
| `test_[method]_[scenario]_[expected]` | `test_login_invalidPassword_throwsError` |
|
|
649
|
+
| `it_[does something]` | `it_calculates_total_correctly` |
|
|
636
650
|
|
|
637
651
|
### 測試資料最佳實踐
|
|
638
652
|
|
|
639
653
|
```typescript
|
|
640
|
-
// ✅
|
|
654
|
+
// ✅ Good: Clear, meaningful test data
|
|
641
655
|
const validUser = {
|
|
642
656
|
email: 'john.doe@example.com',
|
|
643
657
|
password: 'SecureP@ss123',
|
|
644
658
|
role: 'admin'
|
|
645
659
|
};
|
|
646
660
|
|
|
647
|
-
// ❌
|
|
661
|
+
// ❌ Bad: Magic strings without context
|
|
648
662
|
const user = {
|
|
649
663
|
email: 'a@b.c',
|
|
650
664
|
password: '123',
|
|
651
665
|
role: 'x'
|
|
652
666
|
};
|
|
653
667
|
|
|
654
|
-
// ✅
|
|
668
|
+
// ✅ Good: Use test data builders
|
|
655
669
|
const user = UserBuilder.create()
|
|
656
670
|
.withEmail('john.doe@example.com')
|
|
657
671
|
.withRole('admin')
|
|
658
672
|
.build();
|
|
659
673
|
|
|
660
|
-
// ✅
|
|
674
|
+
// ✅ Good: Use constants for boundary values
|
|
661
675
|
const MAX_PASSWORD_LENGTH = 128;
|
|
662
676
|
const MIN_PASSWORD_LENGTH = 8;
|
|
663
677
|
|
|
@@ -669,134 +683,227 @@ test('should reject password exceeding max length', () => {
|
|
|
669
683
|
|
|
670
684
|
### 測試邊界情況
|
|
671
685
|
|
|
672
|
-
確保測試涵蓋 [測試完整性維度](../../core/test-completeness-dimensions.md)
|
|
686
|
+
確保測試涵蓋 [測試完整性維度](../../core/test-completeness-dimensions.md) 中定義的所有八個維度。其中包括正常路徑(happy path)、邊界條件、錯誤處理、授權、狀態變更、驗證、整合以及 AI 生成品質(適用時)。
|
|
673
687
|
|
|
674
|
-
|
|
688
|
+
使用該文件中的檢查清單來驗證各功能的覆蓋率。
|
|
675
689
|
|
|
676
690
|
---
|
|
677
691
|
|
|
678
692
|
## 重構策略
|
|
679
693
|
|
|
680
|
-
###
|
|
694
|
+
### 何時進行重構
|
|
681
695
|
|
|
682
|
-
|
|
696
|
+
當你看到程式碼壞味道(code smell)時就進行重構。使用下方的完整目錄來識別問題與對應的解決方案。
|
|
683
697
|
|
|
684
|
-
|
|
685
|
-
- **過長方法**:函式做太多事
|
|
686
|
-
- **命名不佳**:不清楚的變數/函式名稱
|
|
687
|
-
- **複雜條件**:巢狀的 if/else 鏈
|
|
688
|
-
- **功能嫉妒**:方法過度使用另一個類別的資料
|
|
689
|
-
- **資料團塊**:相同的資料群組一起出現
|
|
698
|
+
### 程式碼壞味道目錄
|
|
690
699
|
|
|
691
|
-
|
|
700
|
+
根據 Martin Fowler 的《重構》(第 2 版),程式碼壞味道分為五大類:
|
|
692
701
|
|
|
693
|
-
|
|
694
|
-
重構前:
|
|
695
|
-
□ 所有測試都通過(綠色)
|
|
696
|
-
□ 有足夠的測試覆蓋
|
|
697
|
-
□ 你理解程式碼在做什麼
|
|
702
|
+
#### 1. 膨脹劑(Bloaters)
|
|
698
703
|
|
|
699
|
-
|
|
700
|
-
□ 一次只做「一個」小變更
|
|
701
|
-
□ 「每次」變更後執行測試
|
|
702
|
-
□ 如果測試失敗,立即復原
|
|
703
|
-
□ 重構時不要新增功能
|
|
704
|
+
程式碼過於龐大而難以處理。
|
|
704
705
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
706
|
+
| 壞味道 | 說明 | 重構手法 |
|
|
707
|
+
|-------|-------------|-------------|
|
|
708
|
+
| **過長函式(Long Method)** | 函式超過 20 行,做太多事情 | 提煉函式(Extract Method)、以查詢取代暫存變數(Replace Temp with Query)、引入參數物件(Introduce Parameter Object) |
|
|
709
|
+
| **過大類別(Large Class)** | 類別承擔過多職責 | 提煉類別(Extract Class)、提煉子類別(Extract Subclass)、提煉介面(Extract Interface) |
|
|
710
|
+
| **基本型別偏執(Primitive Obsession)** | 對簡單任務使用基本型別而非小型物件 | 以物件取代基本型別(Replace Primitive with Object)、以類別取代型別碼(Replace Type Code with Class)、引入參數物件(Introduce Parameter Object) |
|
|
711
|
+
| **過長參數列(Long Parameter List)** | 超過 3 個參數 | 引入參數物件(Introduce Parameter Object)、保持物件完整(Preserve Whole Object)、以函式呼叫取代參數(Replace Parameter with Method Call) |
|
|
712
|
+
| **資料泥團(Data Clumps)** | 相同的一組資料在多處一同出現 | 提煉類別(Extract Class)、引入參數物件(Introduce Parameter Object)、保持物件完整(Preserve Whole Object) |
|
|
710
713
|
|
|
711
|
-
|
|
714
|
+
#### 2. 物件導向濫用者(Object-Orientation Abusers)
|
|
712
715
|
|
|
713
|
-
|
|
714
|
-
|------|---------|------|
|
|
715
|
-
| **提取方法** | 過長方法、重複程式碼 | 提取 10 行到 `calculateDiscount()` |
|
|
716
|
-
| **重新命名** | 不清楚的名稱 | `calc()` → `calculateOrderTotal()` |
|
|
717
|
-
| **內聯** | 過度抽象 | 移除不必要的包裝函式 |
|
|
718
|
-
| **提取變數** | 複雜表達式 | `const isEligible = age >= 18 && hasLicense` |
|
|
719
|
-
| **用多型取代條件** | 複雜的 switch/if 鏈 | 使用策略模式 |
|
|
720
|
-
| **引入參數物件** | 太多參數 | `(x, y, width, height)` → `Rectangle rect` |
|
|
716
|
+
對物件導向原則不完整或不正確的應用。
|
|
721
717
|
|
|
722
|
-
|
|
718
|
+
| 壞味道 | 說明 | 重構手法 |
|
|
719
|
+
|-------|-------------|-------------|
|
|
720
|
+
| **Switch 語句(Switch Statements)** | 依據型別而生的複雜 switch/if-else 鏈 | 以多型取代條件邏輯(Replace Conditional with Polymorphism)、以策略取代型別碼(Replace Type Code with Strategy)、以狀態取代型別碼(Replace Type Code with State) |
|
|
721
|
+
| **暫時性欄位(Temporary Field)** | 僅在特定情況下設定的欄位 | 提煉類別(Extract Class)、引入空物件(Introduce Null Object)、引入特例(Introduce Special Case) |
|
|
722
|
+
| **拒絕繼承(Refused Bequest)** | 子類別未使用繼承的函式 | 下移函式(Push Down Method)、下移欄位(Push Down Field)、以委託取代繼承(Replace Inheritance with Delegation) |
|
|
723
|
+
| **介面不同的替代類別(Alternative Classes with Different Interfaces)** | 做相同事情但函式簽章不同的類別 | 重新命名函式(Rename Method)、搬移函式(Move Method)、提煉超類別(Extract Superclass) |
|
|
724
|
+
| **平行繼承體系(Parallel Inheritance Hierarchies)** | 建立子類別時必須在另一個體系中也建立一個子類別 | 搬移函式(Move Method)、搬移欄位(Move Field) |
|
|
723
725
|
|
|
724
|
-
|
|
726
|
+
#### 3. 變更預防者(Change Preventers)
|
|
725
727
|
|
|
726
|
-
|
|
728
|
+
讓變更比必要更困難的程式碼。
|
|
727
729
|
|
|
728
|
-
|
|
|
729
|
-
|
|
730
|
-
|
|
|
731
|
-
|
|
|
732
|
-
|
|
|
733
|
-
| **Long Parameter List(過長參數列表)** | 方法有太多參數(>3-4 個) | Replace Parameter with Method Call、Preserve Whole Object、Introduce Parameter Object |
|
|
734
|
-
| **Data Clumps(資料泥團)** | 相同的資料群組一起出現 | Extract Class、Introduce Parameter Object、Preserve Whole Object |
|
|
730
|
+
| 壞味道 | 說明 | 重構手法 |
|
|
731
|
+
|-------|-------------|-------------|
|
|
732
|
+
| **發散式變化(Divergent Change)** | 一個類別因許多不同原因而改變 | 提煉類別(Extract Class)、拆分階段(Split Phase) |
|
|
733
|
+
| **散彈式手術(Shotgun Surgery)** | 一個變更需要修改許多類別 | 搬移函式(Move Method)、搬移欄位(Move Field)、內聯函式(Inline Function)、內聯類別(Inline Class) |
|
|
734
|
+
| **平行繼承體系(Parallel Inheritance Hierarchies)** | (見上) | 搬移函式(Move Method)、搬移欄位(Move Field) |
|
|
735
735
|
|
|
736
|
-
####
|
|
736
|
+
#### 4. 可贅除物(Dispensables)
|
|
737
737
|
|
|
738
|
-
|
|
739
|
-
|------|------|---------|
|
|
740
|
-
| **Switch Statements(Switch 語句)** | 複雜的 switch/case 或 if/else 鏈 | Replace Type Code with Subclasses、Replace Conditional with Polymorphism、Replace Parameter with Explicit Methods、Introduce Null Object |
|
|
741
|
-
| **Temporary Field(暫時欄位)** | 只在某些情況下有值的欄位 | Extract Class、Introduce Null Object |
|
|
742
|
-
| **Refused Bequest(被拒絕的遺產)** | 子類別不使用繼承的方法/資料 | Replace Inheritance with Delegation、Push Down Method/Field |
|
|
743
|
-
| **Alternative Classes with Different Interfaces(介面不同的替代類別)** | 做相同事情但有不同介面的類別 | Rename Method、Move Method、Extract Superclass |
|
|
744
|
-
| **Parallel Inheritance Hierarchies(平行繼承階層)** | 每次建立一個類別的子類別就需要建立另一個類別的子類別 | Move Method、Move Field 合併階層 |
|
|
738
|
+
可以被移除的不必要程式碼。
|
|
745
739
|
|
|
746
|
-
|
|
740
|
+
| 壞味道 | 說明 | 重構手法 |
|
|
741
|
+
|-------|-------------|-------------|
|
|
742
|
+
| **註解(Comments)** | 掩蓋糟糕程式碼的過多註解 | 提煉函式(Extract Method)、重新命名函式(Rename Method)、引入斷言(Introduce Assertion) |
|
|
743
|
+
| **重複程式碼(Duplicate Code)** | 多處出現相同或相似的程式碼 | 提煉函式(Extract Method)、上推函式(Pull Up Method)、提煉類別(Extract Class)、搬移陳述句(Slide Statements) |
|
|
744
|
+
| **死碼(Dead Code)** | 未使用的程式碼(變數、函式、類別) | 移除死碼(Remove Dead Code) |
|
|
745
|
+
| **冗贅類別(Lazy Class)** | 做的太少不足以證明其存在價值的類別 | 內聯類別(Inline Class)、折疊體系(Collapse Hierarchy) |
|
|
746
|
+
| **誇誇其談未來性(Speculative Generality)** | 「以備將來之需」的未使用抽象 | 折疊體系(Collapse Hierarchy)、內聯函式(Inline Function)、內聯類別(Inline Class)、移除死碼(Remove Dead Code) |
|
|
747
|
+
| **純資料類別(Data Class)** | 僅有欄位與 getter/setter 的類別 | 搬移函式(Move Method)、封裝欄位(Encapsulate Field)、封裝集合(Encapsulate Collection) |
|
|
747
748
|
|
|
748
|
-
|
|
749
|
-
|------|------|---------|
|
|
750
|
-
| **Divergent Change(發散式變更)** | 一個類別因不同原因經常被修改 | Extract Class 分離不同的關注點 |
|
|
751
|
-
| **Shotgun Surgery(散彈槍手術)** | 一個變更需要修改多個類別 | Move Method、Move Field、Inline Class 合併相關行為 |
|
|
752
|
-
| **Parallel Inheritance Hierarchies(平行繼承階層)** | 每次建立一個類別的子類別就需要建立另一個 | Move Method、Move Field |
|
|
749
|
+
#### 5. 耦合者(Couplers)
|
|
753
750
|
|
|
754
|
-
|
|
751
|
+
類別之間存在過度耦合的程式碼。
|
|
755
752
|
|
|
756
|
-
|
|
|
757
|
-
|
|
758
|
-
|
|
|
759
|
-
|
|
|
760
|
-
|
|
|
761
|
-
|
|
|
762
|
-
| **Speculative Generality(推測式通用性)** | 為「未來可能需要」建立的未使用抽象 | Collapse Hierarchy、Inline Class、Remove Parameter、Rename Method |
|
|
763
|
-
| **Comments(註解)** | 用於解釋難懂程式碼的過多註解 | Extract Method、Rename Method、Introduce Assertion(讓程式碼自我說明) |
|
|
753
|
+
| 壞味道 | 說明 | 重構手法 |
|
|
754
|
+
|-------|-------------|-------------|
|
|
755
|
+
| **依戀情結(Feature Envy)** | 函式使用另一個類別的資料多於自己的資料 | 搬移函式(Move Method)、提煉函式(Extract Method) |
|
|
756
|
+
| **狎暱關係(Inappropriate Intimacy)** | 類別過度緊密耦合,存取彼此的私有部分 | 搬移函式(Move Method)、搬移欄位(Move Field)、隱藏委託(Hide Delegate)、以繼承取代委託(Replace Delegation with Inheritance) |
|
|
757
|
+
| **訊息鏈(Message Chains)** | `a.getB().getC().getD().getValue()` | 隱藏委託(Hide Delegate)、提煉函式(Extract Method)、搬移函式(Move Method) |
|
|
758
|
+
| **中間人(Middle Man)** | 類別只是一味委託給另一個類別 | 移除中間人(Remove Middle Man)、內聯函式(Inline Function)、以委託取代超類別(Replace Superclass with Delegate) |
|
|
764
759
|
|
|
765
|
-
|
|
760
|
+
### 程式碼壞味道偵測檢查清單
|
|
761
|
+
|
|
762
|
+
用於識別常見壞味道的快速檢查清單:
|
|
763
|
+
|
|
764
|
+
```
|
|
765
|
+
函式/方法層級:
|
|
766
|
+
□ 函式 > 20 行? → 提煉函式(Extract Method)
|
|
767
|
+
□ > 3 個參數? → 引入參數物件(Introduce Parameter Object)
|
|
768
|
+
□ 巢狀過深(> 3 層)? → 提煉函式(Extract Method)、以保護子句取代巢狀條件式(Replace Nested Conditional with Guard Clauses)
|
|
769
|
+
□ 多個 return 陳述句? → 考慮重構
|
|
770
|
+
|
|
771
|
+
類別層級:
|
|
772
|
+
□ 類別 > 200 行? → 提煉類別(Extract Class)
|
|
773
|
+
□ > 10 個函式? → 考慮拆分職責
|
|
774
|
+
□ 上帝類別(God class,無所不做)? → 提煉類別(Extract Class)
|
|
775
|
+
□ 純資料類別(僅有欄位)? → 移入行為
|
|
776
|
+
|
|
777
|
+
程式碼模式:
|
|
778
|
+
□ 依型別切換(Switch on type)? → 以多型取代(Replace with Polymorphism)
|
|
779
|
+
□ 複製貼上的程式碼? → 提煉函式/類別(Extract Method/Class)
|
|
780
|
+
□ 未使用的程式碼? → 刪除它
|
|
781
|
+
□ 魔術數字? → 以具名常數取代(Replace with Named Constant)
|
|
782
|
+
```
|
|
766
783
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
784
|
+
### 安全重構檢查清單
|
|
785
|
+
|
|
786
|
+
```
|
|
787
|
+
重構前:
|
|
788
|
+
□ 所有測試皆通過(綠色)
|
|
789
|
+
□ 存在足夠的測試覆蓋率
|
|
790
|
+
□ 你理解程式碼在做什麼
|
|
774
791
|
|
|
775
|
-
|
|
792
|
+
重構期間:
|
|
793
|
+
□ 一次只做一個微小變更
|
|
794
|
+
□ 每次變更後都執行測試
|
|
795
|
+
□ 若測試失敗,立即還原
|
|
796
|
+
□ 重構時不要加入新功能
|
|
776
797
|
|
|
798
|
+
重構後:
|
|
799
|
+
□ 所有測試仍然通過
|
|
800
|
+
□ 程式碼更整潔/更簡單
|
|
801
|
+
□ 未加入任何新功能
|
|
777
802
|
```
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
803
|
+
|
|
804
|
+
### 重構技巧目錄
|
|
805
|
+
|
|
806
|
+
基於 Martin Fowler 的《重構:改善既有程式碼的設計》(第 2 版,2018)。
|
|
807
|
+
|
|
808
|
+
#### 重新組織函式(Composing Methods)
|
|
809
|
+
|
|
810
|
+
| 技巧 | 何時使用 | 範例 |
|
|
811
|
+
|-----------|-------------|---------|
|
|
812
|
+
| **提煉函式(Extract Method)** | 過長函式、重複程式碼 | 將 10 行提煉為 `calculateDiscount()` |
|
|
813
|
+
| **內聯函式(Inline Method)** | 函式本體與其名稱一樣清晰 | 移除微不足道的委託 |
|
|
814
|
+
| **提煉變數(Extract Variable)** | 複雜運算式 | `const isEligible = age >= 18 && hasLicense` |
|
|
815
|
+
| **內聯變數(Inline Variable)** | 變數未增加任何資訊 | 移除 `const x = obj.value; return x;` |
|
|
816
|
+
| **以查詢取代暫存變數(Replace Temp with Query)** | 暫存變數被多次使用 | 轉為函式以供重複使用 |
|
|
817
|
+
| **拆分變數(Split Variable)** | 變數因不同目的被多次賦值 | 建立各自獨立的變數 |
|
|
818
|
+
| **移除對參數的賦值(Remove Assignments to Parameters)** | 令人困惑的參數修改 | 改用區域變數 |
|
|
819
|
+
| **以函式物件取代函式(Replace Method with Method Object)** | 帶有許多區域變數的過長函式 | 提煉至新類別 |
|
|
820
|
+
|
|
821
|
+
#### 在物件之間搬移特性(Moving Features Between Objects)
|
|
822
|
+
|
|
823
|
+
| 技巧 | 何時使用 | 範例 |
|
|
824
|
+
|-----------|-------------|---------|
|
|
825
|
+
| **搬移函式(Move Method)** | 函式使用另一個類別的特性更多 | 搬移至其所依戀的類別 |
|
|
826
|
+
| **搬移欄位(Move Field)** | 欄位被另一個類別使用更多 | 搬移至使用它最多的類別 |
|
|
827
|
+
| **提煉類別(Extract Class)** | 類別做太多事 | 拆分為兩個類別 |
|
|
828
|
+
| **內聯類別(Inline Class)** | 類別做太少事 | 合併至另一個類別 |
|
|
829
|
+
| **隱藏委託(Hide Delegate)** | 用戶端透過委託鏈進行呼叫 | 加入中介函式 |
|
|
830
|
+
| **移除中間人(Remove Middle Man)** | 過多的委託 | 直接公開委託物件 |
|
|
831
|
+
|
|
832
|
+
#### 組織資料(Organizing Data)
|
|
833
|
+
|
|
834
|
+
| 技巧 | 何時使用 | 範例 |
|
|
835
|
+
|-----------|-------------|---------|
|
|
836
|
+
| **以物件取代基本型別(Replace Primitive with Object)** | 帶有行為的基本型別 | `string phoneNumber` → `PhoneNumber` 類別 |
|
|
837
|
+
| **以物件取代資料值(Replace Data Value with Object)** | 資料項目需要額外行為 | 將價格作為帶有幣別的物件 |
|
|
838
|
+
| **以常數取代魔術數字(Replace Magic Number with Constant)** | 程式碼中的魔術數字 | `const MAX_RETRIES = 3` |
|
|
839
|
+
| **封裝欄位(Encapsulate Field)** | 公開欄位 | 加入 getter/setter 函式 |
|
|
840
|
+
| **封裝集合(Encapsulate Collection)** | Getter 直接回傳集合 | 回傳防禦性複本 |
|
|
841
|
+
| **以類別取代型別碼(Replace Type Code with Class)** | 型別碼影響行為 | 改用類別/列舉 |
|
|
842
|
+
| **以子類別取代型別碼(Replace Type Code with Subclasses)** | 型別碼對行為產生不同影響 | 建立子類別體系 |
|
|
843
|
+
| **以狀態/策略取代型別碼(Replace Type Code with State/Strategy)** | 型別碼在執行時期改變 | 使用 State/Strategy 模式 |
|
|
844
|
+
|
|
845
|
+
#### 簡化條件運算式(Simplifying Conditional Expressions)
|
|
846
|
+
|
|
847
|
+
| 技巧 | 何時使用 | 範例 |
|
|
848
|
+
|-----------|-------------|---------|
|
|
849
|
+
| **分解條件式(Decompose Conditional)** | 複雜條件式 | 將條件與分支提煉為函式 |
|
|
850
|
+
| **合併條件運算式(Consolidate Conditional Expression)** | 多個條件具有相同結果 | 使用邏輯運算子合併 |
|
|
851
|
+
| **合併重複的條件片段(Consolidate Duplicate Conditional Fragments)** | 所有分支中皆有相同程式碼 | 移至條件式之外 |
|
|
852
|
+
| **以保護子句取代巢狀條件式(Replace Nested Conditional with Guard Clauses)** | 深度巢狀 | 針對特殊情況提早回傳 |
|
|
853
|
+
| **以多型取代條件邏輯(Replace Conditional with Polymorphism)** | 依型別切換(Switch on type) | 使用多型 |
|
|
854
|
+
| **引入空物件(Introduce Null Object)** | 頻繁的 null 檢查 | 建立 Null Object 類別 |
|
|
855
|
+
| **引入斷言(Introduce Assertion)** | 關於狀態的假設 | 加入明確的斷言 |
|
|
856
|
+
|
|
857
|
+
#### 簡化函式呼叫(Making Method Calls Simpler)
|
|
858
|
+
|
|
859
|
+
| 技巧 | 何時使用 | 範例 |
|
|
860
|
+
|-----------|-------------|---------|
|
|
861
|
+
| **重新命名函式(Rename Method)** | 不清晰的名稱 | `calc()` → `calculateOrderTotal()` |
|
|
862
|
+
| **加入參數(Add Parameter)** | 函式需要更多資料 | 加入必要參數 |
|
|
863
|
+
| **移除參數(Remove Parameter)** | 參數不再使用 | 移除未使用的參數 |
|
|
864
|
+
| **將查詢與修改分離(Separate Query from Modifier)** | 函式同時回傳值並進行修改 | 拆分為兩個函式 |
|
|
865
|
+
| **參數化函式(Parameterize Method)** | 僅有字面值差異的相似函式 | 透過參數進行合併 |
|
|
866
|
+
| **引入參數物件(Introduce Parameter Object)** | 多個參數總是一同傳遞 | `(x, y, w, h)` → `Rectangle` |
|
|
867
|
+
| **保持物件完整(Preserve Whole Object)** | 從物件傳遞多個數值 | 改為傳遞該物件 |
|
|
868
|
+
| **以函式呼叫取代參數(Replace Parameter with Method Call)** | 參數可被計算取得 | 在內部呼叫函式 |
|
|
869
|
+
| **以工廠函式取代建構式(Replace Constructor with Factory Method)** | 複雜的建構邏輯 | 使用工廠函式 |
|
|
870
|
+
|
|
871
|
+
#### 處理概括關係(Dealing with Generalization)
|
|
872
|
+
|
|
873
|
+
| 技巧 | 何時使用 | 範例 |
|
|
874
|
+
|-----------|-------------|---------|
|
|
875
|
+
| **上推欄位(Pull Up Field)** | 子類別中的相同欄位 | 移至超類別 |
|
|
876
|
+
| **上推函式(Pull Up Method)** | 子類別中的相同函式 | 移至超類別 |
|
|
877
|
+
| **下移欄位(Push Down Field)** | 僅被部分子類別使用的欄位 | 移至相關子類別 |
|
|
878
|
+
| **下移函式(Push Down Method)** | 僅被部分子類別使用的函式 | 移至相關子類別 |
|
|
879
|
+
| **提煉超類別(Extract Superclass)** | 相似類別 | 建立共享的超類別 |
|
|
880
|
+
| **提煉介面(Extract Interface)** | 多個類別具有相同的函式子集 | 建立介面 |
|
|
881
|
+
| **折疊體系(Collapse Hierarchy)** | 超類別/子類別差異不夠大 | 合併類別 |
|
|
882
|
+
| **以委託取代繼承(Replace Inheritance with Delegation)** | 子類別不想要所有繼承的函式 | 改用組合(composition) |
|
|
883
|
+
| **以繼承取代委託(Replace Delegation with Inheritance)** | 過多的轉發 | 改為繼承 |
|
|
884
|
+
|
|
885
|
+
#### 快速參考:最常見的重構
|
|
886
|
+
|
|
887
|
+
```
|
|
888
|
+
每日重構(5-15 分鐘):
|
|
889
|
+
├── 重新命名(變數、函式、類別)
|
|
890
|
+
├── 提煉函式
|
|
891
|
+
├── 內聯變數
|
|
892
|
+
├── 以常數取代魔術數字
|
|
893
|
+
└── 提煉變數
|
|
894
|
+
|
|
895
|
+
每週重構(30 分鐘 - 2 小時):
|
|
896
|
+
├── 提煉類別
|
|
897
|
+
├── 搬移函式/欄位
|
|
898
|
+
├── 以多型取代條件邏輯
|
|
899
|
+
├── 引入參數物件
|
|
900
|
+
└── 以物件取代基本型別
|
|
901
|
+
|
|
902
|
+
策略性重構(數天 - 數週):
|
|
903
|
+
├── 以委託取代繼承
|
|
904
|
+
├── 提煉超類別/介面
|
|
905
|
+
├── 引入空物件
|
|
906
|
+
└── 以狀態/策略取代型別碼
|
|
800
907
|
```
|
|
801
908
|
|
|
802
909
|
---
|
|
@@ -806,26 +913,26 @@ test('should reject password exceeding max length', () => {
|
|
|
806
913
|
### 測試替身類型
|
|
807
914
|
|
|
808
915
|
| 類型 | 目的 | 使用時機 |
|
|
809
|
-
|
|
810
|
-
| **Dummy** |
|
|
811
|
-
| **Stub** |
|
|
916
|
+
|------|---------|-------------|
|
|
917
|
+
| **Dummy** | 填補參數列表 | 測試中不需要使用但必填的參數 |
|
|
918
|
+
| **Stub** | 回傳預先定義的值 | 模擬特定情境 |
|
|
812
919
|
| **Spy** | 記錄互動 | 驗證方法是否被呼叫 |
|
|
813
|
-
| **Mock** | 驗證互動 + 回傳值 |
|
|
814
|
-
| **Fake** |
|
|
920
|
+
| **Mock** | 驗證互動 + 回傳值 | 測試行為與協作 |
|
|
921
|
+
| **Fake** | 簡化的可用實作 | 記憶體內部資料庫 |
|
|
815
922
|
|
|
816
923
|
### 依測試層級的測試替身使用
|
|
817
924
|
|
|
818
|
-
| 層級 |
|
|
819
|
-
|
|
820
|
-
| **單元測試** |
|
|
821
|
-
| **整合測試** |
|
|
822
|
-
| **系統測試** |
|
|
823
|
-
| **E2E 測試** |
|
|
925
|
+
| 層級 | 建議替身 |
|
|
926
|
+
|-------|---------------------|
|
|
927
|
+
| **單元測試** | 對所有外部相依使用 Mock、Stub |
|
|
928
|
+
| **整合測試** | 對資料庫使用 Fake,對外部 API 使用 Stub |
|
|
929
|
+
| **系統測試** | 真實元件,僅對外部服務使用 Fake |
|
|
930
|
+
| **E2E 測試** | 全部使用真實元件 |
|
|
824
931
|
|
|
825
|
-
### 範例:使用 Mock
|
|
932
|
+
### 範例:使用 Mock 與 Stub
|
|
826
933
|
|
|
827
934
|
```typescript
|
|
828
|
-
// Stub 範例 -
|
|
935
|
+
// Stub 範例 - 預先定義的回傳值
|
|
829
936
|
const paymentGateway = {
|
|
830
937
|
processPayment: jest.fn().mockResolvedValue({ success: true, transactionId: 'TXN123' })
|
|
831
938
|
};
|
|
@@ -840,7 +947,7 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
840
947
|
|
|
841
948
|
await order.checkout({ amount: 100, email: 'user@example.com' });
|
|
842
949
|
|
|
843
|
-
// 驗證 mock
|
|
950
|
+
// 驗證 mock 是否以正確的引數被呼叫
|
|
844
951
|
expect(emailService.sendConfirmation).toHaveBeenCalledWith(
|
|
845
952
|
'user@example.com',
|
|
846
953
|
expect.objectContaining({ transactionId: 'TXN123' })
|
|
@@ -851,15 +958,15 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
851
958
|
### 避免過度 Mock
|
|
852
959
|
|
|
853
960
|
```
|
|
854
|
-
❌ 過度
|
|
961
|
+
❌ 過度 Mock(測試實作細節):
|
|
855
962
|
- Mock 私有方法
|
|
856
|
-
- Mock
|
|
963
|
+
- Mock 每一個相依套件
|
|
857
964
|
- 驗證每一個內部方法呼叫
|
|
858
965
|
|
|
859
|
-
✅ 適當的
|
|
966
|
+
✅ 適當的 Mock:
|
|
860
967
|
- Mock 外部服務(API、資料庫)
|
|
861
|
-
- Mock
|
|
862
|
-
- Mock
|
|
968
|
+
- Mock 耗時操作(檔案 I/O、網路)
|
|
969
|
+
- Mock 不確定性操作(時間、隨機)
|
|
863
970
|
```
|
|
864
971
|
|
|
865
972
|
---
|
|
@@ -868,65 +975,65 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
868
975
|
|
|
869
976
|
### 程式碼層級反模式
|
|
870
977
|
|
|
871
|
-
| 反模式 | 說明 | 影響 |
|
|
872
|
-
|
|
873
|
-
| **測試實作細節** | 測試私有方法或內部狀態 |
|
|
874
|
-
| **過度 Mock** | Mock 所有東西,失去真實性 |
|
|
875
|
-
|
|
|
876
|
-
| **魔術數字/字串** |
|
|
877
|
-
| **缺少斷言** |
|
|
878
|
-
|
|
|
879
|
-
| **過大的 Arrange
|
|
880
|
-
| **測試中的條件邏輯** |
|
|
881
|
-
| **測試程式碼重複** |
|
|
882
|
-
|
|
|
883
|
-
| **忽略測試失敗** | 跳過或註解掉失敗的測試 |
|
|
884
|
-
| **測試第三方程式碼** |
|
|
885
|
-
|
|
|
886
|
-
|
|
|
887
|
-
|
|
|
978
|
+
| 反模式 | 說明 | 影響 | 修復 |
|
|
979
|
+
|--------------|-------------|--------|-------------|
|
|
980
|
+
| **測試實作細節** | 測試私有方法或內部狀態 | 脆性測試,重構會破壞測試 | 僅測試公開行為 |
|
|
981
|
+
| **過度 Mock** | Mock 所有東西,失去真實性 | 虛假信心,正式環境出現 bug | 在 Mock 與真實元件間取得平衡 |
|
|
982
|
+
| **測試相互依賴** | 測試依賴執行順序 | 隨機失敗,難以隔離 | 每個測試設置自己的狀態 |
|
|
983
|
+
| **魔術數字/字串** | 未賦予意義的寫死數值 | 可讀性差,維護惡夢 | 使用具名常數、Builder |
|
|
984
|
+
| **缺少斷言** | 測試缺乏適當的斷言 | 偽陽性(假警報) | 每個測試都需要明確的斷言 |
|
|
985
|
+
| **不穩定測試 (Flaky Tests)** | 有時通過,有時失敗 | 侵蝕對測試套件的信任 | 消除時間/順序相依性 |
|
|
986
|
+
| **過大的 Arrange 區段** | 每個測試都有複雜的設置 | 難以理解、維護 | 將設置抽取至 Builder/Fixture |
|
|
987
|
+
| **測試中的條件邏輯** | 測試程式碼中出現 if/else | 多個測試混在同一個測試裡 | 拆分為獨立的測試 |
|
|
988
|
+
| **測試程式碼重複** | 許多測試中有一樣的設置 | 維護負擔 | 抽取共用設置 |
|
|
989
|
+
| **過度具體的斷言** | 斷言每一個欄位 | 脆性測試 | 僅斷言相關欄位 |
|
|
990
|
+
| **忽略測試失敗** | 跳過或註解掉失敗的測試 | 隱藏 bug | 修復或移除失敗的測試 |
|
|
991
|
+
| **測試第三方程式碼** | 測試函式庫/框架行為 | 浪費精力 | 信任第三方,測試自己的程式碼 |
|
|
992
|
+
| **單一龐大測試** | 單一測試涵蓋所有東西 | 難以診斷失敗原因 | 拆分為專注的小測試 |
|
|
993
|
+
| **無意義的測試名稱** | `test1`、`test2` | 無法理解 | 使用具描述性的名稱 |
|
|
994
|
+
| **捕捉所有例外** | 測試中使用 `catch (Exception e)` | 隱藏失敗 | 捕捉特定例外 |
|
|
888
995
|
|
|
889
996
|
### 流程層級反模式
|
|
890
997
|
|
|
891
|
-
| 反模式 | 說明 | 影響 |
|
|
892
|
-
|
|
893
|
-
| **跳過紅色階段** |
|
|
894
|
-
| **跳過重構階段** |
|
|
895
|
-
|
|
|
896
|
-
|
|
|
897
|
-
| **100%
|
|
898
|
-
|
|
|
899
|
-
| **延遲執行測試** | 不常執行測試 |
|
|
900
|
-
|
|
|
901
|
-
| **TDD 狂熱** |
|
|
902
|
-
|
|
|
998
|
+
| 反模式 | 說明 | 影響 | 修復 |
|
|
999
|
+
|--------------|-------------|--------|-------------|
|
|
1000
|
+
| **跳過紅色階段** | 在寫測試之前先寫程式碼 | 失去 TDD 設計效益 | 紀律:始終先撰寫失敗的測試 |
|
|
1001
|
+
| **跳過重構階段** | 從不清理程式碼 | 技術債累積 | 排定重構時間 |
|
|
1002
|
+
| **後測開發 (TAD)** | 程式碼完成後才寫測試 | 非 TDD,錯失設計回饋 | 真正的 TDD:測試優先 |
|
|
1003
|
+
| **大霹靂測試撰寫** | 一次寫完所有測試 | 難以招架,覆蓋率不佳 | 一次一個測試 |
|
|
1004
|
+
| **100% 覆蓋率執念** | 盲目追求覆蓋率指標 | 毫無意義的測試 | 聚焦於行為覆蓋率 |
|
|
1005
|
+
| **缺乏測試審查** | PR 中未審查測試 | 測試品質差 | 在程式碼審查中納入測試 |
|
|
1006
|
+
| **延遲執行測試** | 不常執行測試 | 回饋太晚 | 持續執行測試 |
|
|
1007
|
+
| **忽略緩慢測試** | 任由測試套件變慢 | 開發者跳過測試 | 最佳化或平行化 |
|
|
1008
|
+
| **TDD 狂熱** | 在所有地方強推 TDD | 團隊感到沮喪 | 務實應用 TDD |
|
|
1009
|
+
| **缺乏測試維護** | 任由測試腐爛 | 偽陽性/偽陰性 | 將測試視為正式環境程式碼 |
|
|
903
1010
|
|
|
904
1011
|
### 診斷與修復步驟
|
|
905
1012
|
|
|
906
1013
|
```
|
|
907
1014
|
┌─────────────────────────────────────────────────────────────────┐
|
|
908
|
-
│ 反模式診斷工作流程
|
|
1015
|
+
│ 反模式診斷工作流程 │
|
|
909
1016
|
├─────────────────────────────────────────────────────────────────┤
|
|
910
1017
|
│ │
|
|
911
|
-
│
|
|
912
|
-
│ ├─ 可能原因:測試實作細節
|
|
913
|
-
│ └─
|
|
1018
|
+
│ 症狀:重構時測試經常損壞 │
|
|
1019
|
+
│ ├─ 可能原因:測試實作細節 │
|
|
1020
|
+
│ └─ 修復:審查測試,確保僅測試行為 │
|
|
914
1021
|
│ │
|
|
915
|
-
│ 症狀:測試通過但 bug
|
|
916
|
-
│ ├─ 可能原因:過度
|
|
917
|
-
│ └─
|
|
1022
|
+
│ 症狀:測試通過但 bug 流入正式環境 │
|
|
1023
|
+
│ ├─ 可能原因:過度 Mock、缺少邊界情況 │
|
|
1024
|
+
│ └─ 修復:加入整合測試,審查覆蓋率缺口 │
|
|
918
1025
|
│ │
|
|
919
|
-
│ 症狀:測試隨機失敗
|
|
920
|
-
│ ├─
|
|
921
|
-
│ └─ 修復:隔離測試,
|
|
1026
|
+
│ 症狀:測試隨機失敗 │
|
|
1027
|
+
│ ├─ 可能原因:測試相互依賴、時序問題 │
|
|
1028
|
+
│ └─ 修復:隔離測試,Mock 與時間相依的操作 │
|
|
922
1029
|
│ │
|
|
923
|
-
│
|
|
924
|
-
│ ├─
|
|
925
|
-
│ └─
|
|
1030
|
+
│ 症狀:測試套件耗時過長 │
|
|
1031
|
+
│ ├─ 可能原因:太多整合測試、緩慢的 I/O │
|
|
1032
|
+
│ └─ 修復:提高單元測試比例、平行化執行 │
|
|
926
1033
|
│ │
|
|
927
|
-
│
|
|
928
|
-
│ ├─
|
|
929
|
-
│ └─
|
|
1034
|
+
│ 症狀:團隊排斥寫測試 │
|
|
1035
|
+
│ ├─ 可能原因:測試過於複雜、工具支援差 │
|
|
1036
|
+
│ └─ 修復:簡化測試設置,改善測試公用程式 │
|
|
930
1037
|
│ │
|
|
931
1038
|
└─────────────────────────────────────────────────────────────────┘
|
|
932
1039
|
```
|
|
@@ -935,13 +1042,13 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
935
1042
|
|
|
936
1043
|
## 語言/框架實踐
|
|
937
1044
|
|
|
938
|
-
|
|
939
|
-
- [
|
|
1045
|
+
有關特定語言的詳細 TDD 範例,請參閱 TDD Assistant 技能:
|
|
1046
|
+
- [Language Examples](../skills/tdd-assistant/language-examples.md)
|
|
940
1047
|
|
|
941
|
-
###
|
|
1048
|
+
### 依語言速查手冊
|
|
942
1049
|
|
|
943
|
-
| 語言 | 測試框架 | Mock
|
|
944
|
-
|
|
1050
|
+
| 語言 | 測試框架 | Mock 函式庫 | BDD 工具 |
|
|
1051
|
+
|----------|---------------|--------------|----------|
|
|
945
1052
|
| **JavaScript/TypeScript** | Jest, Vitest | jest.mock, vitest.mock | Cucumber.js |
|
|
946
1053
|
| **Python** | pytest, unittest | unittest.mock, pytest-mock | Behave |
|
|
947
1054
|
| **C#** | xUnit, NUnit, MSTest | Moq, NSubstitute | SpecFlow |
|
|
@@ -951,36 +1058,36 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
951
1058
|
|
|
952
1059
|
### 框架選擇指南
|
|
953
1060
|
|
|
954
|
-
|
|
|
955
|
-
|
|
956
|
-
| **新專案** | 使用 IDE
|
|
957
|
-
| **團隊經驗** |
|
|
958
|
-
| **現有程式碼庫** |
|
|
959
|
-
| **需要 BDD** |
|
|
960
|
-
| **速度關鍵** |
|
|
1061
|
+
| 考量因素 | 建議 |
|
|
1062
|
+
|---------------|----------------|
|
|
1063
|
+
| **新專案** | 使用 IDE 支援最佳的框架 |
|
|
1064
|
+
| **團隊經驗** | 使用團隊最熟悉的工具 |
|
|
1065
|
+
| **現有程式碼庫** | 與現有測試框架一致 |
|
|
1066
|
+
| **需要 BDD** | 選擇具備 BDD 整合支援的框架 |
|
|
1067
|
+
| **速度關鍵** | 考量平行執行支援能力 |
|
|
961
1068
|
|
|
962
1069
|
---
|
|
963
1070
|
|
|
964
|
-
##
|
|
1071
|
+
## 指標與評估
|
|
965
1072
|
|
|
966
1073
|
### TDD 成熟度模型
|
|
967
1074
|
|
|
968
|
-
|
|
|
969
|
-
|
|
970
|
-
|
|
|
971
|
-
|
|
|
972
|
-
|
|
|
973
|
-
|
|
|
974
|
-
|
|
|
1075
|
+
| 等級 | 名稱 | 特徵 |
|
|
1076
|
+
|-------|------|-----------------|
|
|
1077
|
+
| **等級 0** | 無 TDD | 測試在寫完程式碼後才寫,甚至完全不寫 |
|
|
1078
|
+
| **等級 1** | 測試優先 (Test-First) | 有時在寫程式碼之前先寫測試 |
|
|
1079
|
+
| **等級 2** | TDD 實踐者 | 一貫遵循紅-綠-重構循環 |
|
|
1080
|
+
| **等級 3** | TDD 專家 | 有效運用測試替身,測試乾淨俐落 |
|
|
1081
|
+
| **等級 4** | TDD 大師 | TDD 驅動設計,指導他人 |
|
|
975
1082
|
|
|
976
1083
|
### 關鍵指標
|
|
977
1084
|
|
|
978
|
-
| 指標 | 目標 |
|
|
979
|
-
|
|
1085
|
+
| 指標 | 目標 | 警示門檻 |
|
|
1086
|
+
|--------|--------|-------------------|
|
|
980
1087
|
| **程式碼覆蓋率** | > 80% | < 60% |
|
|
981
|
-
|
|
|
982
|
-
| **測試執行時間** | < 30
|
|
983
|
-
|
|
|
1088
|
+
| **測試與程式碼比例** | 1:1 至 2:1 | < 0.5:1 |
|
|
1089
|
+
| **測試執行時間** | < 30 秒(單元測試) | > 2 分鐘 |
|
|
1090
|
+
| **不穩定測試比例** | 0% | > 1% |
|
|
984
1091
|
| **測試維護成本** | < 15% 開發時間 | > 30% |
|
|
985
1092
|
| **缺陷逃逸率** | 下降中 | 上升中 |
|
|
986
1093
|
|
|
@@ -989,14 +1096,14 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
989
1096
|
```
|
|
990
1097
|
團隊 TDD 評估:
|
|
991
1098
|
|
|
992
|
-
□
|
|
1099
|
+
□ 測試在生產程式碼之前撰寫
|
|
993
1100
|
□ 遵循紅-綠-重構循環
|
|
994
1101
|
□ 測試名稱清楚描述行為
|
|
995
|
-
□
|
|
1102
|
+
□ 測試具備獨立性與可重複性
|
|
996
1103
|
□ 測試套件執行快速(< 2 分鐘)
|
|
997
|
-
□
|
|
1104
|
+
□ 無不穩定測試
|
|
998
1105
|
□ 足夠的覆蓋率(> 80%)
|
|
999
|
-
□
|
|
1106
|
+
□ 程式碼審查中包含測試審查
|
|
1000
1107
|
□ 定期進行重構
|
|
1001
1108
|
□ CI/CD 自動執行測試
|
|
1002
1109
|
```
|
|
@@ -1005,12 +1112,13 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
1005
1112
|
|
|
1006
1113
|
## 相關標準
|
|
1007
1114
|
|
|
1008
|
-
- [
|
|
1009
|
-
- [
|
|
1010
|
-
- [
|
|
1011
|
-
- [
|
|
1012
|
-
- [
|
|
1013
|
-
- [
|
|
1115
|
+
- [Testing Standards](../../core/testing-standards.md) - 核心測試標準 (UT/IT/ST/E2E)(或使用 `/testing-guide` 技能)
|
|
1116
|
+
- [Test Completeness Dimensions](../../core/test-completeness-dimensions.md) - 八維度框架
|
|
1117
|
+
- [Behavior-Driven Development](../../core/behavior-driven-development.md) - 採用 Given-When-Then 格式的 BDD 工作流程
|
|
1118
|
+
- [Acceptance Test-Driven Development](../../core/acceptance-test-driven-development.md) - 包含規格工作坊的 ATDD 工作流程
|
|
1119
|
+
- [Spec-Driven Development](../../core/spec-driven-development.md) - SDD 工作流程
|
|
1120
|
+
- [Code Check-in Standards](../../core/checkin-standards.md) - 簽入要求
|
|
1121
|
+
- [Code Review Checklist](../../core/code-review-checklist.md) - 審查指南
|
|
1014
1122
|
|
|
1015
1123
|
---
|
|
1016
1124
|
|
|
@@ -1027,29 +1135,30 @@ test('should send confirmation email after successful payment', async () => {
|
|
|
1027
1135
|
|
|
1028
1136
|
- [IEEE 29119 - 軟體測試標準](https://www.iso.org/standard/81291.html)
|
|
1029
1137
|
- [SWEBOK v4.0 - 第 5 章:軟體建構](https://www.computer.org/education/bodies-of-knowledge/software-engineering)
|
|
1030
|
-
- [ISTQB
|
|
1138
|
+
- [ISTQB Certified Tester Foundation Level](https://www.istqb.org/)
|
|
1031
1139
|
|
|
1032
1140
|
### 線上資源
|
|
1033
1141
|
|
|
1034
1142
|
- [TDD by Example - Martin Fowler](https://martinfowler.com/bliki/TestDrivenDevelopment.html)
|
|
1035
1143
|
- [The Three Rules of TDD - Uncle Bob](http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd)
|
|
1036
1144
|
- [Test Pyramid - Martin Fowler](https://martinfowler.com/bliki/TestPyramid.html)
|
|
1145
|
+
- [Double-Loop TDD - Samman Coaching](https://sammancoaching.org/learning_hours/bdd/double_loop_tdd.html) - 解說 BDD 外循環 / TDD 內循環模式
|
|
1037
1146
|
- [Approval Tests](https://approvaltests.com/)
|
|
1038
1147
|
|
|
1039
1148
|
---
|
|
1040
1149
|
|
|
1041
1150
|
## 版本歷史
|
|
1042
1151
|
|
|
1043
|
-
| 版本 | 日期 |
|
|
1044
|
-
|
|
1045
|
-
| 1.2.0 | 2026-01-25 |
|
|
1046
|
-
| 1.1.0 | 2026-01-12 |
|
|
1152
|
+
| 版本 | 日期 | 變更 |
|
|
1153
|
+
|---------|------|---------|
|
|
1154
|
+
| 1.2.0 | 2026-01-25 | 新增:方法論分類章節(傳統開發方法論定位、與 SDD 的關係) |
|
|
1155
|
+
| 1.1.0 | 2026-01-12 | 新增:完整程式碼壞味道目錄(基於 Martin Fowler《Refactoring》第 2 版,分為 5 大類共 22+ 種壞味道)、程式碼壞味道偵測檢查清單 |
|
|
1047
1156
|
| 1.0.0 | 2026-01-07 | 初始 TDD 標準定義 |
|
|
1048
1157
|
|
|
1049
1158
|
---
|
|
1050
1159
|
|
|
1051
1160
|
## 授權
|
|
1052
1161
|
|
|
1053
|
-
本標準依據 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
|
|
1162
|
+
本標準依據 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 釋出。
|
|
1054
1163
|
|
|
1055
1164
|
**來源**: [universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)
|