universal-dev-standards 4.2.0 → 5.0.0-beta.10
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/README.md +3 -3
- package/bin/uds.js +165 -5
- package/bundled/core/acceptance-test-driven-development.md +19 -721
- package/bundled/core/accessibility-standards.md +862 -0
- package/bundled/core/ai-agreement-standards.md +95 -0
- package/bundled/core/ai-friendly-architecture.md +2 -0
- package/bundled/core/ai-instruction-standards.md +2 -0
- package/bundled/core/anti-hallucination.md +90 -637
- package/bundled/core/behavior-driven-development.md +20 -735
- package/bundled/core/changelog-standards.md +4 -0
- package/bundled/core/checkin-standards.md +21 -4
- package/bundled/core/code-review-checklist.md +3 -0
- package/bundled/core/commit-message-guide.md +14 -3
- package/bundled/core/deployment-standards.md +296 -0
- package/bundled/core/developer-memory.md +568 -0
- package/bundled/core/documentation-structure.md +114 -18
- package/bundled/core/documentation-writing-standards.md +272 -2
- package/bundled/core/error-code-standards.md +3 -0
- package/bundled/core/forward-derivation-standards.md +134 -8
- package/bundled/core/git-workflow.md +72 -686
- package/bundled/core/guides/anti-hallucination-guide.md +517 -0
- package/bundled/core/guides/git-workflow-guide.md +954 -0
- package/bundled/core/guides/performance-guide.md +508 -0
- package/bundled/core/guides/refactoring-guide.md +608 -0
- package/bundled/core/guides/security-guide.md +485 -0
- package/bundled/core/logging-standards.md +337 -2
- package/bundled/core/performance-standards.md +231 -0
- package/bundled/core/project-context-memory.md +180 -0
- package/bundled/core/project-structure.md +315 -2
- package/bundled/core/refactoring-standards.md +81 -761
- package/bundled/core/requirement-engineering.md +39 -0
- package/bundled/core/reverse-engineering-standards.md +6 -4
- package/bundled/core/security-standards.md +244 -0
- package/bundled/core/spec-driven-development.md +20 -319
- package/bundled/core/test-completeness-dimensions.md +213 -11
- package/bundled/core/test-driven-development.md +22 -978
- package/bundled/core/testing-standards.md +222 -2903
- package/bundled/core/versioning.md +16 -55
- package/bundled/core/virtual-organization-standards.md +85 -0
- package/bundled/locales/README.md +4 -4
- package/bundled/locales/zh-CN/CHANGELOG.md +18 -18
- package/bundled/locales/zh-CN/CLAUDE.md +3 -3
- package/bundled/locales/zh-CN/MAINTENANCE.md +7 -7
- package/bundled/locales/zh-CN/README.md +2 -2
- package/bundled/locales/zh-CN/STANDARDS-MAPPING.md +1 -1
- package/bundled/locales/zh-CN/adoption/ADOPTION-GUIDE.md +3 -3
- package/bundled/locales/zh-CN/adoption/DAILY-WORKFLOW-GUIDE.md +66 -7
- package/bundled/locales/zh-CN/adoption/STATIC-DYNAMIC-GUIDE.md +22 -22
- package/bundled/locales/zh-CN/adoption/checklists/enterprise.md +5 -5
- package/bundled/locales/zh-CN/adoption/checklists/minimal.md +4 -4
- package/bundled/locales/zh-CN/adoption/checklists/recommended.md +5 -5
- package/bundled/locales/zh-CN/ai/MAINTENANCE.md +13 -13
- package/bundled/locales/zh-CN/core/ai-instruction-standards.md +1 -1
- package/bundled/locales/zh-CN/core/anti-hallucination.md +39 -3
- package/bundled/locales/zh-CN/core/checkin-standards.md +18 -5
- package/bundled/locales/zh-CN/core/commit-message-guide.md +1 -1
- package/bundled/locales/zh-CN/core/developer-memory.md +576 -0
- package/bundled/locales/zh-CN/core/documentation-structure.md +43 -5
- package/bundled/locales/zh-CN/core/documentation-writing-standards.md +146 -5
- package/bundled/locales/zh-CN/core/git-workflow.md +179 -4
- package/bundled/locales/zh-CN/core/logging-standards.md +177 -4
- package/bundled/locales/zh-CN/core/project-structure.md +117 -5
- package/bundled/locales/zh-CN/core/refactoring-standards.md +3 -3
- package/bundled/locales/zh-CN/core/reverse-engineering-standards.md +6 -6
- package/bundled/locales/zh-CN/core/spec-driven-development.md +516 -14
- package/bundled/locales/zh-CN/core/test-completeness-dimensions.md +155 -24
- package/bundled/locales/zh-CN/core/test-driven-development.md +71 -20
- package/bundled/locales/zh-CN/core/testing-standards.md +4 -4
- package/bundled/locales/zh-CN/core/versioning.md +1 -1
- package/bundled/locales/zh-CN/docs/AI-AGENT-ROADMAP.md +90 -51
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +184 -0
- package/bundled/locales/zh-CN/docs/CLI-FLOW.md +239 -0
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +320 -0
- package/bundled/locales/zh-CN/docs/OPERATION-WORKFLOW.md +43 -43
- package/bundled/locales/zh-CN/docs/STANDARDS-REFERENCE.md +440 -0
- package/bundled/locales/zh-CN/docs/USAGE-MODES-COMPARISON.md +1 -1
- package/bundled/locales/zh-CN/docs/WINDOWS-GUIDE.md +1 -1
- package/bundled/locales/zh-CN/integrations/codex/README.md +3 -3
- package/bundled/locales/zh-CN/integrations/gemini-cli/README.md +3 -3
- package/bundled/locales/zh-CN/integrations/github-copilot/README.md +5 -5
- package/bundled/locales/zh-CN/integrations/github-copilot/copilot-instructions.md +9 -9
- package/bundled/locales/zh-CN/integrations/github-copilot/skills-mapping.md +18 -6
- package/bundled/locales/zh-CN/integrations/google-antigravity/README.md +2 -2
- package/bundled/locales/zh-CN/integrations/opencode/README.md +3 -3
- package/bundled/locales/zh-CN/integrations/opencode/skills-mapping.md +22 -10
- package/bundled/locales/zh-CN/integrations/openspec/README.md +1 -1
- package/bundled/locales/zh-CN/integrations/spec-kit/AGENTS.md +3 -3
- package/bundled/locales/zh-CN/integrations/spec-kit/README.md +1 -1
- package/bundled/locales/zh-CN/options/commit-message/bilingual.md +1 -1
- package/bundled/locales/zh-CN/options/commit-message/english.md +1 -1
- package/bundled/locales/zh-CN/options/commit-message/traditional-chinese.md +1 -1
- package/bundled/locales/zh-CN/options/git-workflow/gitflow.md +1 -1
- package/bundled/locales/zh-CN/options/git-workflow/github-flow.md +1 -1
- package/bundled/locales/zh-CN/options/git-workflow/merge-commit.md +1 -1
- package/bundled/locales/zh-CN/options/git-workflow/rebase-ff.md +1 -1
- package/bundled/locales/zh-CN/options/git-workflow/squash-merge.md +1 -1
- package/bundled/locales/zh-CN/options/git-workflow/trunk-based.md +1 -1
- package/bundled/locales/zh-CN/options/project-structure/dotnet.md +1 -1
- package/bundled/locales/zh-CN/options/project-structure/go.md +1 -1
- package/bundled/locales/zh-CN/options/project-structure/java.md +1 -1
- package/bundled/locales/zh-CN/options/project-structure/nodejs.md +1 -1
- package/bundled/locales/zh-CN/options/project-structure/python.md +1 -1
- package/bundled/locales/zh-CN/options/testing/e2e-testing.md +1 -1
- package/bundled/locales/zh-CN/options/testing/integration-testing.md +1 -1
- package/bundled/locales/zh-CN/options/testing/system-testing.md +1 -1
- package/bundled/locales/zh-CN/options/testing/unit-testing.md +1 -1
- package/bundled/locales/zh-CN/skills/{claude-code/CONTRIBUTING.template.md → CONTRIBUTING.template.md} +2 -2
- package/bundled/locales/zh-CN/skills/README.md +131 -81
- package/bundled/locales/zh-CN/skills/agents/README.md +281 -0
- package/bundled/locales/zh-CN/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/SKILL.md +10 -10
- package/bundled/locales/zh-CN/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/anti-hallucination.md +8 -8
- package/bundled/locales/zh-CN/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/certainty-labels.md +8 -8
- package/bundled/locales/zh-CN/skills/ai-friendly-architecture/SKILL.md +221 -0
- package/bundled/locales/zh-CN/skills/ai-instruction-standards/SKILL.md +214 -0
- package/bundled/locales/zh-CN/skills/atdd-assistant/SKILL.md +71 -0
- package/bundled/locales/zh-CN/skills/atdd-assistant/acceptance-criteria-guide.md +428 -0
- package/bundled/locales/zh-CN/skills/atdd-assistant/atdd-workflow.md +484 -0
- package/bundled/locales/zh-CN/skills/atdd-assistant/guide.md +368 -0
- package/bundled/locales/zh-CN/skills/bdd-assistant/SKILL.md +68 -0
- package/bundled/locales/zh-CN/skills/bdd-assistant/bdd-workflow.md +406 -0
- package/bundled/locales/zh-CN/skills/bdd-assistant/gherkin-guide.md +454 -0
- package/bundled/locales/zh-CN/skills/bdd-assistant/guide.md +324 -0
- package/bundled/locales/zh-CN/skills/changelog-guide/SKILL.md +64 -0
- package/bundled/locales/zh-CN/skills/{claude-code/changelog-guide/SKILL.md → changelog-guide/guide.md} +6 -7
- package/bundled/locales/zh-CN/skills/checkin-assistant/SKILL.md +56 -0
- package/bundled/locales/zh-CN/skills/{claude-code/checkin-assistant/SKILL.md → checkin-assistant/guide.md} +6 -7
- package/bundled/locales/zh-CN/skills/code-review-assistant/SKILL.md +56 -0
- package/bundled/locales/zh-CN/skills/{claude-code/code-review-assistant → code-review-assistant}/checkin-checklist.md +4 -4
- package/bundled/locales/zh-CN/skills/{claude-code/code-review-assistant/SKILL.md → code-review-assistant/guide.md} +5 -6
- package/bundled/locales/zh-CN/skills/{claude-code/code-review-assistant → code-review-assistant}/review-checklist.md +4 -4
- package/bundled/locales/zh-CN/skills/{claude-code/commands → commands}/bdd.md +2 -2
- package/bundled/locales/zh-CN/skills/{claude-code/commands → commands}/methodology.md +3 -3
- package/bundled/locales/zh-CN/skills/{claude-code/commands → commands}/refactor.md +3 -3
- package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +61 -0
- package/bundled/locales/zh-CN/skills/{claude-code/commit-standards → commit-standards}/conventional-commits.md +4 -4
- package/bundled/locales/zh-CN/skills/{claude-code/commit-standards/SKILL.md → commit-standards/guide.md} +5 -6
- package/bundled/locales/zh-CN/skills/{claude-code/commit-standards → commit-standards}/language-options.md +3 -3
- package/bundled/locales/zh-CN/skills/docs-generator/SKILL.md +59 -0
- package/bundled/locales/zh-CN/skills/docs-generator/guide.md +262 -0
- package/bundled/locales/zh-CN/skills/{claude-code/documentation-guide → documentation-guide}/SKILL.md +7 -8
- package/bundled/locales/zh-CN/skills/{claude-code/documentation-guide → documentation-guide}/documentation-structure.md +4 -4
- package/bundled/locales/zh-CN/skills/{claude-code/documentation-guide → documentation-guide}/readme-template.md +3 -3
- package/bundled/locales/zh-CN/skills/{claude-code/error-code-guide → error-code-guide}/SKILL.md +6 -6
- package/bundled/locales/zh-CN/skills/forward-derivation/SKILL.md +62 -0
- package/bundled/locales/zh-CN/skills/forward-derivation/guide.md +130 -0
- package/bundled/locales/zh-CN/skills/{claude-code/git-workflow-guide → git-workflow-guide}/SKILL.md +6 -6
- package/bundled/locales/zh-CN/skills/{claude-code/git-workflow-guide → git-workflow-guide}/branch-naming.md +3 -3
- package/bundled/locales/zh-CN/skills/{claude-code/git-workflow-guide → git-workflow-guide}/git-workflow.md +4 -4
- package/bundled/locales/zh-CN/skills/{claude-code/logging-guide → logging-guide}/SKILL.md +6 -6
- package/bundled/locales/zh-CN/skills/methodology-system/SKILL.md +78 -0
- package/bundled/locales/zh-CN/skills/{claude-code/methodology-system → methodology-system}/create-methodology.md +2 -2
- package/bundled/locales/zh-CN/skills/{claude-code/methodology-system/SKILL.md → methodology-system/guide.md} +2 -2
- package/bundled/locales/zh-CN/skills/{claude-code/methodology-system → methodology-system}/runtime.md +3 -3
- package/bundled/locales/zh-CN/skills/project-discovery/SKILL.md +66 -0
- package/bundled/locales/zh-CN/skills/project-discovery/guide.md +371 -0
- package/bundled/locales/zh-CN/skills/{claude-code/project-structure-guide → project-structure-guide}/SKILL.md +4 -4
- package/bundled/locales/zh-CN/skills/{claude-code/project-structure-guide → project-structure-guide}/language-patterns.md +1 -1
- package/bundled/locales/zh-CN/skills/refactoring-assistant/SKILL.md +67 -0
- package/bundled/locales/zh-CN/skills/{claude-code/refactoring-assistant/SKILL.md → refactoring-assistant/guide.md} +7 -8
- package/bundled/locales/zh-CN/skills/release-standards/SKILL.md +64 -0
- package/bundled/locales/zh-CN/skills/{claude-code/release-standards → release-standards}/changelog-format.md +3 -3
- package/bundled/locales/zh-CN/skills/{claude-code/release-standards/SKILL.md → release-standards/guide.md} +5 -6
- package/bundled/locales/zh-CN/skills/{claude-code/release-standards → release-standards}/release-workflow.md +7 -7
- package/bundled/locales/zh-CN/skills/{claude-code/release-standards → release-standards}/semantic-versioning.md +3 -3
- package/bundled/locales/zh-CN/skills/requirement-assistant/SKILL.md +67 -0
- package/bundled/locales/zh-CN/skills/{claude-code/requirement-assistant/SKILL.md → requirement-assistant/guide.md} +4 -5
- package/bundled/locales/zh-CN/skills/{claude-code/requirement-assistant → requirement-assistant}/requirement-checklist.md +3 -3
- package/bundled/locales/zh-CN/skills/{claude-code/requirement-assistant → requirement-assistant}/requirement-writing.md +3 -3
- package/bundled/locales/zh-CN/skills/reverse-engineer/SKILL.md +67 -0
- package/bundled/locales/zh-CN/skills/{claude-code/reverse-engineer → reverse-engineer}/bdd-extraction.md +2 -2
- package/bundled/locales/zh-CN/skills/{claude-code/reverse-engineer/SKILL.md → reverse-engineer/guide.md} +17 -18
- package/bundled/locales/zh-CN/skills/{claude-code/reverse-engineer → reverse-engineer}/tdd-analysis.md +2 -2
- package/bundled/locales/zh-CN/skills/{claude-code/reverse-engineer → reverse-engineer}/workflow.md +3 -3
- package/bundled/locales/zh-CN/skills/spec-driven-dev/SKILL.md +75 -0
- package/bundled/locales/zh-CN/skills/{claude-code/spec-driven-dev/SKILL.md → spec-driven-dev/guide.md} +10 -11
- package/bundled/locales/zh-CN/skills/tdd-assistant/SKILL.md +66 -0
- package/bundled/locales/zh-CN/skills/{claude-code/tdd-assistant/SKILL.md → tdd-assistant/guide.md} +12 -16
- package/bundled/locales/zh-CN/skills/{claude-code/tdd-assistant → tdd-assistant}/language-examples.md +3 -3
- package/bundled/locales/zh-CN/skills/{claude-code/tdd-assistant → tdd-assistant}/tdd-workflow.md +3 -3
- package/bundled/locales/zh-CN/skills/test-coverage-assistant/SKILL.md +65 -0
- package/bundled/locales/zh-CN/skills/test-coverage-assistant/guide.md +284 -0
- package/bundled/locales/zh-CN/skills/{claude-code/testing-guide → testing-guide}/SKILL.md +8 -8
- package/bundled/locales/zh-CN/skills/{claude-code/testing-guide → testing-guide}/testing-pyramid.md +4 -4
- package/bundled/locales/zh-CN/skills/{cline → tools/cline}/README.md +1 -1
- package/bundled/locales/zh-CN/skills/{copilot → tools/copilot}/README.md +1 -1
- package/bundled/locales/zh-CN/skills/{copilot → tools/copilot}/copilot-instructions.md +1 -1
- package/bundled/locales/zh-CN/skills/{cursor → tools/cursor}/README.md +1 -1
- package/bundled/locales/zh-CN/skills/{windsurf → tools/windsurf}/README.md +1 -1
- package/bundled/locales/zh-TW/CHANGELOG.md +16 -16
- package/bundled/locales/zh-TW/CLAUDE.md +3 -3
- package/bundled/locales/zh-TW/MAINTENANCE.md +7 -7
- package/bundled/locales/zh-TW/README.md +13 -7
- package/bundled/locales/zh-TW/STANDARDS-MAPPING.md +1 -1
- package/bundled/locales/zh-TW/adoption/ADOPTION-GUIDE.md +4 -4
- package/bundled/locales/zh-TW/adoption/DAILY-WORKFLOW-GUIDE.md +66 -7
- package/bundled/locales/zh-TW/adoption/STATIC-DYNAMIC-GUIDE.md +22 -22
- package/bundled/locales/zh-TW/adoption/checklists/enterprise.md +5 -5
- package/bundled/locales/zh-TW/adoption/checklists/minimal.md +4 -4
- package/bundled/locales/zh-TW/adoption/checklists/recommended.md +5 -5
- package/bundled/locales/zh-TW/ai/MAINTENANCE.md +13 -13
- package/bundled/locales/zh-TW/ai/standards/anti-hallucination.ai.yaml +3 -2
- package/bundled/locales/zh-TW/ai/standards/git-workflow.ai.yaml +4 -3
- package/bundled/locales/zh-TW/ai/standards/spec-driven-development.ai.yaml +3 -3
- package/bundled/locales/zh-TW/ai/standards/testing.ai.yaml +1 -0
- package/bundled/locales/zh-TW/core/ai-instruction-standards.md +1 -1
- package/bundled/locales/zh-TW/core/anti-hallucination.md +38 -701
- package/bundled/locales/zh-TW/core/changelog-standards.md +1 -1
- package/bundled/locales/zh-TW/core/checkin-standards.md +18 -5
- package/bundled/locales/zh-TW/core/code-review-checklist.md +1 -1
- package/bundled/locales/zh-TW/core/commit-message-guide.md +1 -1
- package/bundled/locales/zh-TW/core/developer-memory.md +576 -0
- package/bundled/locales/zh-TW/core/documentation-structure.md +115 -22
- package/bundled/locales/zh-TW/core/documentation-writing-standards.md +126 -5
- package/bundled/locales/zh-TW/core/forward-derivation-standards.md +2 -2
- package/bundled/locales/zh-TW/core/git-workflow.md +38 -812
- package/bundled/locales/zh-TW/core/guides/anti-hallucination-guide.md +779 -0
- package/bundled/locales/zh-TW/core/guides/git-workflow-guide.md +1016 -0
- package/bundled/locales/zh-TW/core/guides/refactoring-guide.md +864 -0
- package/bundled/locales/zh-TW/core/guides/testing-guide.md +2280 -0
- package/bundled/locales/zh-TW/core/logging-standards.md +159 -4
- package/bundled/locales/zh-TW/core/project-structure.md +102 -9
- package/bundled/locales/zh-TW/core/refactoring-standards.md +37 -823
- package/bundled/locales/zh-TW/core/reverse-engineering-standards.md +6 -6
- package/bundled/locales/zh-TW/core/spec-driven-development.md +17 -268
- package/bundled/locales/zh-TW/core/test-completeness-dimensions.md +128 -14
- package/bundled/locales/zh-TW/core/test-driven-development.md +20 -983
- package/bundled/locales/zh-TW/core/testing-standards.md +120 -2105
- package/bundled/locales/zh-TW/core/versioning.md +13 -55
- package/bundled/locales/zh-TW/docs/AI-AGENT-ROADMAP.md +90 -51
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +184 -0
- package/bundled/locales/zh-TW/docs/CLI-FLOW.md +239 -0
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +320 -0
- package/bundled/locales/zh-TW/docs/MIGRATION-V5.md +71 -0
- package/bundled/locales/zh-TW/docs/OPERATION-WORKFLOW.md +42 -42
- package/bundled/locales/zh-TW/docs/STANDARDS-REFERENCE.md +440 -0
- package/bundled/locales/zh-TW/docs/USAGE-MODES-COMPARISON.md +1 -1
- package/bundled/locales/zh-TW/docs/WINDOWS-GUIDE.md +1 -1
- package/bundled/locales/zh-TW/integrations/claude-code/README.md +44 -0
- package/bundled/locales/zh-TW/integrations/github-copilot/copilot-instructions.md +3 -3
- package/bundled/locales/zh-TW/integrations/github-copilot/skills-mapping.md +18 -6
- package/bundled/locales/zh-TW/integrations/opencode/skills-mapping.md +22 -10
- package/bundled/locales/zh-TW/methodologies/guides/sdd-guide.md +338 -0
- package/bundled/locales/zh-TW/methodologies/guides/tdd-guide.md +1055 -0
- package/bundled/locales/zh-TW/options/commit-message/bilingual.md +1 -1
- package/bundled/locales/zh-TW/options/commit-message/english.md +1 -1
- package/bundled/locales/zh-TW/options/commit-message/traditional-chinese.md +1 -1
- package/bundled/locales/zh-TW/options/git-workflow/gitflow.md +1 -1
- package/bundled/locales/zh-TW/options/git-workflow/github-flow.md +1 -1
- package/bundled/locales/zh-TW/options/git-workflow/merge-commit.md +1 -1
- package/bundled/locales/zh-TW/options/git-workflow/rebase-ff.md +1 -1
- package/bundled/locales/zh-TW/options/git-workflow/squash-merge.md +1 -1
- package/bundled/locales/zh-TW/options/git-workflow/trunk-based.md +1 -1
- package/bundled/locales/zh-TW/options/project-structure/dotnet.md +1 -1
- package/bundled/locales/zh-TW/options/project-structure/go.md +1 -1
- package/bundled/locales/zh-TW/options/project-structure/java.md +1 -1
- package/bundled/locales/zh-TW/options/project-structure/nodejs.md +1 -1
- package/bundled/locales/zh-TW/options/project-structure/python.md +1 -1
- package/bundled/locales/zh-TW/options/testing/e2e-testing.md +1 -1
- package/bundled/locales/zh-TW/options/testing/integration-testing.md +1 -1
- package/bundled/locales/zh-TW/options/testing/system-testing.md +1 -1
- package/bundled/locales/zh-TW/options/testing/unit-testing.md +1 -1
- package/bundled/locales/zh-TW/skills/{claude-code/CONTRIBUTING.template.md → CONTRIBUTING.template.md} +2 -2
- package/bundled/locales/zh-TW/skills/README.md +131 -79
- package/bundled/locales/zh-TW/skills/agents/README.md +281 -0
- package/bundled/locales/zh-TW/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/SKILL.md +7 -7
- package/bundled/locales/zh-TW/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/anti-hallucination.md +8 -8
- package/bundled/locales/zh-TW/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/certainty-labels.md +8 -8
- package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +221 -0
- package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +214 -0
- package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +71 -0
- package/bundled/locales/zh-TW/skills/atdd-assistant/acceptance-criteria-guide.md +428 -0
- package/bundled/locales/zh-TW/skills/atdd-assistant/atdd-workflow.md +484 -0
- package/bundled/locales/zh-TW/skills/atdd-assistant/guide.md +368 -0
- package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +68 -0
- package/bundled/locales/zh-TW/skills/bdd-assistant/bdd-workflow.md +406 -0
- package/bundled/locales/zh-TW/skills/bdd-assistant/gherkin-guide.md +454 -0
- package/bundled/locales/zh-TW/skills/bdd-assistant/guide.md +324 -0
- package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +64 -0
- package/bundled/locales/zh-TW/skills/{claude-code/changelog-guide/SKILL.md → changelog-guide/guide.md} +6 -7
- package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +56 -0
- package/bundled/locales/zh-TW/skills/{claude-code/checkin-assistant/SKILL.md → checkin-assistant/guide.md} +6 -7
- package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +56 -0
- package/bundled/locales/zh-TW/skills/{claude-code/code-review-assistant → code-review-assistant}/checkin-checklist.md +4 -4
- package/bundled/locales/zh-TW/skills/{claude-code/code-review-assistant/SKILL.md → code-review-assistant/guide.md} +2 -3
- package/bundled/locales/zh-TW/skills/{claude-code/code-review-assistant → code-review-assistant}/review-checklist.md +4 -4
- package/bundled/locales/zh-TW/skills/{claude-code/commands → commands}/bdd.md +2 -2
- package/bundled/locales/zh-TW/skills/{claude-code/commands → commands}/methodology.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/commands → commands}/refactor.md +3 -3
- package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +61 -0
- package/bundled/locales/zh-TW/skills/{claude-code/commit-standards → commit-standards}/conventional-commits.md +4 -4
- package/bundled/locales/zh-TW/skills/{claude-code/commit-standards/SKILL.md → commit-standards/guide.md} +5 -6
- package/bundled/locales/zh-TW/skills/{claude-code/commit-standards → commit-standards}/language-options.md +3 -3
- package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +59 -0
- package/bundled/locales/zh-TW/skills/docs-generator/guide.md +262 -0
- package/bundled/locales/zh-TW/skills/{claude-code/documentation-guide → documentation-guide}/SKILL.md +7 -8
- package/bundled/locales/zh-TW/skills/{claude-code/documentation-guide → documentation-guide}/documentation-structure.md +4 -4
- package/bundled/locales/zh-TW/skills/{claude-code/documentation-guide → documentation-guide}/readme-template.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/error-code-guide → error-code-guide}/SKILL.md +6 -6
- package/bundled/locales/zh-TW/skills/forward-derivation/SKILL.md +62 -0
- package/bundled/locales/zh-TW/skills/{claude-code/forward-derivation/SKILL.md → forward-derivation/guide.md} +24 -19
- package/bundled/locales/zh-TW/skills/{claude-code/git-workflow-guide → git-workflow-guide}/SKILL.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/git-workflow-guide → git-workflow-guide}/branch-naming.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/git-workflow-guide → git-workflow-guide}/git-workflow.md +4 -4
- package/bundled/locales/zh-TW/skills/{claude-code/logging-guide → logging-guide}/SKILL.md +6 -6
- package/bundled/locales/zh-TW/skills/methodology-system/SKILL.md +78 -0
- package/bundled/locales/zh-TW/skills/{claude-code/methodology-system → methodology-system}/create-methodology.md +2 -2
- package/bundled/locales/zh-TW/skills/{claude-code/methodology-system/SKILL.md → methodology-system/guide.md} +2 -2
- package/bundled/locales/zh-TW/skills/{claude-code/methodology-system → methodology-system}/runtime.md +3 -3
- package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +66 -0
- package/bundled/locales/zh-TW/skills/project-discovery/guide.md +371 -0
- package/bundled/locales/zh-TW/skills/project-discovery/workflow.md +574 -0
- package/bundled/locales/zh-TW/skills/{claude-code/project-structure-guide → project-structure-guide}/SKILL.md +4 -4
- package/bundled/locales/zh-TW/skills/{claude-code/project-structure-guide → project-structure-guide}/language-patterns.md +1 -1
- package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +67 -0
- package/bundled/locales/zh-TW/skills/{claude-code/refactoring-assistant/SKILL.md → refactoring-assistant/guide.md} +7 -8
- package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +64 -0
- package/bundled/locales/zh-TW/skills/{claude-code/release-standards → release-standards}/changelog-format.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/release-standards/SKILL.md → release-standards/guide.md} +2 -3
- package/bundled/locales/zh-TW/skills/{claude-code/release-standards → release-standards}/release-workflow.md +60 -28
- package/bundled/locales/zh-TW/skills/{claude-code/release-standards → release-standards}/semantic-versioning.md +3 -3
- package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +67 -0
- package/bundled/locales/zh-TW/skills/{claude-code/requirement-assistant/SKILL.md → requirement-assistant/guide.md} +2 -3
- package/bundled/locales/zh-TW/skills/{claude-code/requirement-assistant → requirement-assistant}/requirement-checklist.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/requirement-assistant → requirement-assistant}/requirement-writing.md +3 -3
- package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +67 -0
- package/bundled/locales/zh-TW/skills/{claude-code/reverse-engineer → reverse-engineer}/bdd-extraction.md +2 -2
- package/bundled/locales/zh-TW/skills/{claude-code/reverse-engineer/SKILL.md → reverse-engineer/guide.md} +17 -18
- package/bundled/locales/zh-TW/skills/{claude-code/reverse-engineer → reverse-engineer}/tdd-analysis.md +2 -2
- package/bundled/locales/zh-TW/skills/{claude-code/reverse-engineer → reverse-engineer}/workflow.md +3 -3
- package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +75 -0
- package/bundled/locales/zh-TW/skills/{claude-code/spec-driven-dev/SKILL.md → spec-driven-dev/guide.md} +9 -10
- package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +66 -0
- package/bundled/locales/zh-TW/skills/{claude-code/tdd-assistant/SKILL.md → tdd-assistant/guide.md} +9 -10
- package/bundled/locales/zh-TW/skills/{claude-code/tdd-assistant → tdd-assistant}/language-examples.md +3 -3
- package/bundled/locales/zh-TW/skills/{claude-code/tdd-assistant → tdd-assistant}/tdd-workflow.md +3 -3
- package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +65 -0
- package/bundled/locales/zh-TW/skills/{claude-code/test-coverage-assistant/SKILL.md → test-coverage-assistant/guide.md} +27 -24
- package/bundled/locales/zh-TW/skills/{claude-code/testing-guide → testing-guide}/SKILL.md +6 -6
- package/bundled/locales/zh-TW/skills/{claude-code/testing-guide → testing-guide}/testing-pyramid.md +4 -4
- package/bundled/locales/zh-TW/skills/{cline → tools/cline}/README.md +1 -1
- package/bundled/locales/zh-TW/skills/{copilot → tools/copilot}/README.md +1 -1
- package/bundled/locales/zh-TW/skills/{copilot → tools/copilot}/copilot-instructions.md +1 -1
- package/bundled/locales/zh-TW/skills/{cursor → tools/cursor}/README.md +1 -1
- package/bundled/locales/zh-TW/skills/{windsurf → tools/windsurf}/README.md +1 -1
- package/bundled/skills/INTEGRATION-GUIDE.md +210 -0
- package/bundled/skills/README.md +95 -0
- package/bundled/skills/_shared/README.md +60 -0
- package/bundled/skills/{claude-code/agents → agents}/README.md +2 -2
- package/bundled/skills/{claude-code/agents → agents}/code-architect.md +1 -1
- package/bundled/skills/{claude-code/agents → agents}/doc-writer.md +1 -1
- package/bundled/skills/{claude-code/agents → agents}/reviewer.md +1 -1
- package/bundled/skills/{claude-code/agents → agents}/spec-analyst.md +1 -1
- package/bundled/skills/{claude-code/agents → agents}/test-specialist.md +1 -1
- package/bundled/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/SKILL.md +28 -5
- package/bundled/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/anti-hallucination.md +24 -5
- package/bundled/skills/{claude-code/ai-collaboration-standards → ai-collaboration-standards}/certainty-labels.md +31 -6
- package/bundled/skills/ai-friendly-architecture/SKILL.md +216 -0
- package/bundled/skills/ai-instruction-standards/SKILL.md +209 -0
- package/bundled/skills/atdd-assistant/SKILL.md +74 -0
- package/bundled/skills/{claude-code/atdd-assistant → atdd-assistant}/acceptance-criteria-guide.md +1 -1
- package/bundled/skills/{claude-code/atdd-assistant → atdd-assistant}/atdd-workflow.md +1 -1
- package/bundled/skills/{claude-code/atdd-assistant/SKILL.md → atdd-assistant/guide.md} +11 -11
- package/bundled/skills/bdd-assistant/SKILL.md +70 -0
- package/bundled/skills/{claude-code/bdd-assistant → bdd-assistant}/bdd-workflow.md +1 -1
- package/bundled/skills/{claude-code/bdd-assistant → bdd-assistant}/gherkin-guide.md +1 -1
- package/bundled/skills/{claude-code/bdd-assistant/SKILL.md → bdd-assistant/guide.md} +11 -11
- package/bundled/skills/changelog-guide/SKILL.md +66 -0
- package/bundled/skills/{claude-code/changelog-guide/SKILL.md → changelog-guide/guide.md} +8 -6
- package/bundled/skills/checkin-assistant/SKILL.md +52 -0
- package/bundled/skills/{claude-code/checkin-assistant/SKILL.md → checkin-assistant/guide.md} +6 -6
- package/bundled/skills/code-review-assistant/SKILL.md +53 -0
- package/bundled/skills/{claude-code/code-review-assistant → code-review-assistant}/checkin-checklist.md +3 -3
- package/bundled/skills/{claude-code/code-review-assistant/SKILL.md → code-review-assistant/guide.md} +7 -5
- package/bundled/skills/{claude-code/code-review-assistant → code-review-assistant}/review-checklist.md +3 -3
- package/bundled/skills/commands/COMMAND-FAMILY-OVERVIEW.md +290 -0
- package/bundled/skills/{claude-code/commands → commands}/README.md +13 -3
- package/bundled/skills/{claude-code/commands → commands}/atdd.md +3 -3
- package/bundled/skills/{claude-code/commands → commands}/bdd.md +2 -2
- package/bundled/skills/commands/changelog.md +58 -0
- package/bundled/skills/{claude-code/commands → commands}/check.md +1 -1
- package/bundled/skills/commands/checkin.md +53 -0
- package/bundled/skills/{claude-code/commands → commands}/commit.md +3 -3
- package/bundled/skills/{claude-code/commands → commands}/config.md +1 -1
- package/bundled/skills/{claude-code/commands → commands}/coverage.md +5 -4
- package/bundled/skills/commands/derive-all.md +53 -0
- package/bundled/skills/commands/derive-atdd.md +49 -0
- package/bundled/skills/commands/derive-bdd.md +47 -0
- package/bundled/skills/commands/derive-tdd.md +48 -0
- package/bundled/skills/commands/derive.md +72 -0
- package/bundled/skills/commands/discover.md +80 -0
- package/bundled/skills/commands/docgen.md +61 -0
- package/bundled/skills/commands/docs.md +59 -0
- package/bundled/skills/commands/guide.md +44 -0
- package/bundled/skills/{claude-code/commands → commands}/init.md +2 -2
- package/bundled/skills/{claude-code/commands → commands}/methodology.md +32 -16
- package/bundled/skills/{claude-code/commands → commands}/refactor.md +2 -2
- package/bundled/skills/commands/release.md +56 -0
- package/bundled/skills/{claude-code/commands → commands}/requirement.md +3 -3
- package/bundled/skills/commands/reverse-bdd.md +47 -0
- package/bundled/skills/commands/reverse-sdd.md +51 -0
- package/bundled/skills/commands/reverse-tdd.md +51 -0
- package/bundled/skills/commands/reverse.md +63 -0
- package/bundled/skills/{claude-code/commands → commands}/review.md +3 -3
- package/bundled/skills/commands/sdd.md +135 -0
- package/bundled/skills/{claude-code/commands → commands}/tdd.md +3 -3
- package/bundled/skills/{claude-code/commands → commands}/update.md +2 -2
- package/bundled/skills/commit-standards/SKILL.md +60 -0
- package/bundled/skills/{claude-code/commit-standards → commit-standards}/conventional-commits.md +3 -3
- package/bundled/skills/{claude-code/commit-standards/SKILL.md → commit-standards/guide.md} +17 -5
- package/bundled/skills/{claude-code/commit-standards → commit-standards}/language-options.md +2 -2
- package/bundled/skills/docs-generator/SKILL.md +69 -0
- package/bundled/skills/docs-generator/guide.md +258 -0
- package/bundled/skills/{claude-code/documentation-guide → documentation-guide}/SKILL.md +7 -7
- package/bundled/skills/{claude-code/documentation-guide → documentation-guide}/documentation-structure.md +3 -3
- package/bundled/skills/{claude-code/documentation-guide → documentation-guide}/readme-template.md +2 -2
- package/bundled/skills/{claude-code/error-code-guide → error-code-guide}/SKILL.md +7 -5
- package/bundled/skills/forward-derivation/SKILL.md +61 -0
- package/bundled/skills/{claude-code/forward-derivation/SKILL.md → forward-derivation/guide.md} +44 -29
- package/bundled/skills/{claude-code/git-workflow-guide → git-workflow-guide}/SKILL.md +7 -5
- package/bundled/skills/{claude-code/git-workflow-guide → git-workflow-guide}/branch-naming.md +2 -2
- package/bundled/skills/{claude-code/git-workflow-guide → git-workflow-guide}/git-workflow.md +3 -3
- package/bundled/skills/{claude-code/logging-guide → logging-guide}/SKILL.md +7 -5
- package/bundled/skills/methodology-system/SKILL.md +75 -0
- package/bundled/skills/{claude-code/methodology-system → methodology-system}/create-methodology.md +1 -1
- package/bundled/skills/{claude-code/methodology-system/SKILL.md → methodology-system/guide.md} +51 -16
- package/bundled/skills/methodology-system/integrated-flow.md +454 -0
- package/bundled/skills/{claude-code/methodology-system → methodology-system}/runtime.md +2 -2
- package/bundled/skills/project-discovery/SKILL.md +63 -0
- package/bundled/skills/project-discovery/guide.md +367 -0
- package/bundled/skills/project-discovery/workflow.md +566 -0
- package/bundled/skills/{claude-code/project-structure-guide → project-structure-guide}/SKILL.md +14 -4
- package/bundled/skills/refactoring-assistant/SKILL.md +78 -0
- package/bundled/skills/{claude-code/refactoring-assistant/SKILL.md → refactoring-assistant/guide.md} +7 -7
- package/bundled/skills/release-standards/SKILL.md +61 -0
- package/bundled/skills/{claude-code/release-standards → release-standards}/changelog-format.md +2 -2
- package/bundled/skills/{claude-code/release-standards/SKILL.md → release-standards/guide.md} +7 -5
- package/bundled/skills/{claude-code/release-standards → release-standards}/release-workflow.md +59 -24
- package/bundled/skills/{claude-code/release-standards → release-standards}/semantic-versioning.md +2 -2
- package/bundled/skills/requirement-assistant/SKILL.md +66 -0
- package/bundled/skills/{claude-code/requirement-assistant/SKILL.md → requirement-assistant/guide.md} +14 -6
- package/bundled/skills/{claude-code/requirement-assistant → requirement-assistant}/requirement-checklist.md +2 -2
- package/bundled/skills/{claude-code/requirement-assistant → requirement-assistant}/requirement-writing.md +2 -2
- package/bundled/skills/reverse-engineer/SKILL.md +64 -0
- package/bundled/skills/{claude-code/reverse-engineer → reverse-engineer}/bdd-extraction.md +1 -1
- package/bundled/skills/{claude-code/reverse-engineer/SKILL.md → reverse-engineer/guide.md} +21 -18
- package/bundled/skills/{claude-code/reverse-engineer → reverse-engineer}/tdd-analysis.md +1 -1
- package/bundled/skills/{claude-code/reverse-engineer → reverse-engineer}/workflow.md +2 -2
- package/bundled/skills/spec-driven-dev/SKILL.md +80 -0
- package/bundled/skills/{claude-code/spec-driven-dev/SKILL.md → spec-driven-dev/guide.md} +50 -8
- package/bundled/skills/tdd-assistant/SKILL.md +65 -0
- package/bundled/skills/{claude-code/tdd-assistant/SKILL.md → tdd-assistant/guide.md} +10 -10
- package/bundled/skills/{claude-code/tdd-assistant → tdd-assistant}/language-examples.md +3 -3
- package/bundled/skills/{claude-code/tdd-assistant → tdd-assistant}/tdd-workflow.md +2 -2
- package/bundled/skills/test-coverage-assistant/SKILL.md +63 -0
- package/bundled/skills/{claude-code/test-coverage-assistant/SKILL.md → test-coverage-assistant/guide.md} +39 -24
- package/bundled/skills/{claude-code/testing-guide → testing-guide}/SKILL.md +12 -7
- package/bundled/skills/{claude-code/testing-guide → testing-guide}/testing-pyramid.md +3 -3
- package/bundled/skills/testing-guide/testing-theory.md +2291 -0
- package/bundled/skills/tools/cline/.clinerules +79 -0
- package/bundled/skills/tools/cline/README.md +50 -0
- package/bundled/skills/tools/copilot/README.md +99 -0
- package/bundled/skills/tools/copilot/copilot-instructions.md +71 -0
- package/bundled/skills/tools/cursor/.cursorrules +101 -0
- package/bundled/skills/tools/cursor/README.md +50 -0
- package/bundled/skills/tools/windsurf/.windsurfrules +76 -0
- package/bundled/skills/tools/windsurf/README.md +51 -0
- package/bundled/skills/{claude-code/workflows → workflows}/README.md +1 -1
- package/bundled/skills/workflows/release.workflow.yaml +893 -0
- package/package.json +4 -1
- package/src/commands/check.js +195 -130
- package/src/commands/config.js +1262 -0
- package/src/commands/configure.js +3 -950
- package/src/commands/fix.js +53 -0
- package/src/commands/hitl.js +19 -0
- package/src/commands/init.js +320 -1030
- package/src/commands/list.js +1 -1
- package/src/commands/simulate.js +61 -0
- package/src/commands/spec.js +288 -0
- package/src/commands/start.js +373 -0
- package/src/commands/sweep.js +142 -0
- package/src/commands/update.js +136 -19
- package/src/commands/workflow.js +265 -1
- package/src/config/ai-agent-paths.js +89 -29
- package/src/core/constants.js +7 -1
- package/src/core/manifest.js +1 -0
- package/src/flows/init-flow.js +243 -0
- package/src/hitl/checkpoint.js +80 -0
- package/src/hitl/classifier.js +54 -0
- package/src/hitl/manager.js +88 -0
- package/src/i18n/messages.js +907 -99
- package/src/index.js +1 -0
- package/src/installers/integration-installer.js +237 -0
- package/src/installers/manifest-installer.js +131 -0
- package/src/installers/skills-installer.js +286 -0
- package/src/installers/standards-installer.js +193 -0
- package/src/missions/MissionManager.js +501 -0
- package/src/prompts/init.js +228 -130
- package/src/prompts/integrations.js +13 -1
- package/src/schemas/standard.schema.json +117 -0
- package/src/utils/agents-installer.js +2 -2
- package/src/utils/config-loader.js +47 -0
- package/src/utils/config-manager.js +108 -0
- package/src/utils/config-merger.js +47 -0
- package/src/utils/github.js +22 -18
- package/src/utils/inquirer-patch.js +98 -0
- package/src/utils/integration-generator.js +392 -58
- package/src/utils/reference-sync.js +69 -19
- package/src/utils/skills-installer.js +6 -3
- package/src/utils/standard-fixer.js +141 -0
- package/src/utils/standard-validator.js +329 -0
- package/src/utils/workflow-executor.js +886 -0
- package/src/utils/workflow-state.js +404 -0
- package/src/utils/workflows-installer.js +2 -2
- package/src/vibe/auto-sweep.js +349 -0
- package/src/vibe/micro-spec.js +428 -0
- package/standards-registry.json +278 -102
- package/bundled/locales/zh-CN/skills/claude-code/README.md +0 -174
- package/bundled/locales/zh-CN/skills/claude-code/test-coverage-assistant/SKILL.md +0 -282
- package/bundled/locales/zh-TW/skills/claude-code/README.md +0 -174
- package/bundled/skills/claude-code/README.md +0 -215
- package/bundled/skills/claude-code/commands/changelog.md +0 -57
- package/bundled/skills/claude-code/commands/derive-all.md +0 -214
- package/bundled/skills/claude-code/commands/derive-atdd.md +0 -177
- package/bundled/skills/claude-code/commands/derive-bdd.md +0 -158
- package/bundled/skills/claude-code/commands/derive-tdd.md +0 -259
- package/bundled/skills/claude-code/commands/docs.md +0 -75
- package/bundled/skills/claude-code/commands/release.md +0 -50
- package/bundled/skills/claude-code/commands/reverse-bdd.md +0 -264
- package/bundled/skills/claude-code/commands/reverse-spec.md +0 -185
- package/bundled/skills/claude-code/commands/reverse-tdd.md +0 -351
- package/bundled/skills/claude-code/commands/spec.md +0 -69
- package/bundled/skills/claude-code/methodology-system/integrated-flow.md +0 -322
- /package/bundled/skills/{claude-code/CONTRIBUTING.template.md → CONTRIBUTING.template.md} +0 -0
- /package/bundled/skills/{claude-code/ai → ai}/standards/checkin.ai.yaml +0 -0
- /package/bundled/skills/{claude-code/ai → ai}/standards/commit.ai.yaml +0 -0
- /package/bundled/skills/{claude-code/ai → ai}/standards/refactoring.ai.yaml +0 -0
- /package/bundled/skills/{claude-code/ai → ai}/standards/testing.ai.yaml +0 -0
- /package/bundled/skills/{claude-code/project-structure-guide → project-structure-guide}/language-patterns.md +0 -0
- /package/bundled/skills/{claude-code/workflows → workflows}/code-review.workflow.yaml +0 -0
- /package/bundled/skills/{claude-code/workflows → workflows}/feature-dev.workflow.yaml +0 -0
- /package/bundled/skills/{claude-code/workflows → workflows}/integrated-flow.workflow.yaml +0 -0
- /package/bundled/skills/{claude-code/workflows → workflows}/large-codebase-analysis.workflow.yaml +0 -0
|
@@ -1,1925 +1,226 @@
|
|
|
1
|
-
---
|
|
2
|
-
source: ../../../core/testing-standards.md
|
|
3
|
-
source_version: 2.2.0
|
|
4
|
-
translation_version: 2.2.0
|
|
5
|
-
last_synced: 2026-01-20
|
|
6
|
-
status: current
|
|
7
|
-
---
|
|
8
|
-
|
|
9
1
|
# 測試標準
|
|
10
2
|
|
|
11
3
|
> **語言**: [English](../../../core/testing-standards.md) | 繁體中文
|
|
12
4
|
|
|
13
|
-
**版本**:
|
|
14
|
-
**最後更新**: 2026-
|
|
15
|
-
|
|
5
|
+
**版本**: 3.0.0
|
|
6
|
+
**最後更新**: 2026-02-10
|
|
7
|
+
**適用性**: 所有軟體專案
|
|
8
|
+
**範圍**: 通用 (Universal)
|
|
16
9
|
|
|
17
10
|
---
|
|
18
11
|
|
|
19
12
|
## 目的
|
|
20
13
|
|
|
21
|
-
|
|
14
|
+
本標準為 AI 代理和開發人員定義可執行的測試規則和慣例。關於理論基礎、教育內容和詳細範例,請參閱 **[測試理論知識庫](guides/testing-guide.md)**。
|
|
22
15
|
|
|
23
|
-
|
|
16
|
+
**參考標準**:
|
|
24
17
|
- [ISTQB CTFL v4.0](https://istqb.org/certifications/certified-tester-foundation-level-ctfl-v4-0/)
|
|
25
18
|
- [ISO/IEC/IEEE 29119](https://www.iso.org/standard/81291.html)
|
|
26
|
-
- [SWEBOK v4.0](https://www.computer.org/education/bodies-of-knowledge/software-engineering)
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## 目錄
|
|
31
|
-
|
|
32
|
-
1. [測試基礎](#測試基礎) ⭐ 新增
|
|
33
|
-
2. [測試框架選擇](#測試框架選擇)
|
|
34
|
-
3. [測試金字塔](#測試金字塔預設業界標準)
|
|
35
|
-
4. [測試層級](#單元測試-ut)(UT、IT、ST、E2E)
|
|
36
|
-
5. [靜態測試](#靜態測試)
|
|
37
|
-
6. [測試設計技術](#測試設計技術)
|
|
38
|
-
7. [經驗導向測試](#經驗導向測試)
|
|
39
|
-
8. [風險導向測試](#風險導向測試)
|
|
40
|
-
9. [專項測試](#專項測試)
|
|
41
|
-
10. [測試相關度量](#測試相關度量) ⭐ 新增
|
|
42
|
-
11. [缺陷管理](#缺陷管理)
|
|
43
|
-
12. [測試流程管理](#測試流程管理)
|
|
44
|
-
13. [測試替身](#測試替身)
|
|
45
|
-
14. [測試資料管理](#測試資料管理)
|
|
46
|
-
15. [測試環境隔離](#測試環境隔離)
|
|
47
|
-
16. [CI/CD 整合](#cicd-整合)
|
|
48
|
-
17. [最佳實踐](#最佳實踐)
|
|
49
|
-
18. [測試文件結構](#測試文件結構) ⭐ 新增
|
|
19
|
+
- [SWEBOK v4.0](https://www.computer.org/education/bodies-of-knowledge/software-engineering)
|
|
50
20
|
|
|
51
21
|
---
|
|
52
22
|
|
|
53
|
-
##
|
|
54
|
-
|
|
55
|
-
了解軟體測試的理論基礎對於有效的測試設計和執行至關重要。
|
|
56
|
-
|
|
57
|
-
**參考來源**:SWEBOK v4.0 第 5 章
|
|
23
|
+
## 術語表
|
|
58
24
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
63
|
-
│ 錯誤、缺陷與失效 │
|
|
64
|
-
├─────────────────────────────────────────────────────────────┤
|
|
65
|
-
│ │
|
|
66
|
-
│ Error(錯誤/人為失誤) │
|
|
67
|
-
│ │ │
|
|
68
|
-
│ ▼ 開發過程中引入 │
|
|
69
|
-
│ ┌─────────┐ │
|
|
70
|
-
│ │ Fault │ (缺陷/Bug,程式碼中的問題) │
|
|
71
|
-
│ └─────────┘ │
|
|
72
|
-
│ │ │
|
|
73
|
-
│ ▼ 執行時 │
|
|
74
|
-
│ ┌─────────┐ │
|
|
75
|
-
│ │ Failure │ (失效,可觀察到的錯誤行為) │
|
|
76
|
-
│ └─────────┘ │
|
|
77
|
-
│ │
|
|
78
|
-
│ 重點: │
|
|
79
|
-
│ • 缺陷可能存在但不一定導致失效 │
|
|
80
|
-
│ • 失效需要缺陷被執行才會發生 │
|
|
81
|
-
│ • 多個缺陷可能導致相同的失效 │
|
|
82
|
-
│ • 測試發現失效;除錯找出缺陷 │
|
|
83
|
-
│ │
|
|
84
|
-
└─────────────────────────────────────────────────────────────┘
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### 測試預言問題(Oracle Problem)
|
|
88
|
-
|
|
89
|
-
**測試預言(Oracle)** 是任何用於判斷程式行為是否正確的機制。測試預言問題探討如何知道預期結果的挑戰。
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
93
|
-
│ 預言類型 │
|
|
94
|
-
├─────────────────────────────────────────────────────────────┤
|
|
95
|
-
│ │
|
|
96
|
-
│ 人工預言 │
|
|
97
|
-
│ └── 由領域專家手動驗證 │
|
|
98
|
-
│ │
|
|
99
|
-
│ 規格導向預言 │
|
|
100
|
-
│ └── 與正式需求規格比對 │
|
|
101
|
-
│ │
|
|
102
|
-
│ 參考實作 │
|
|
103
|
-
│ └── 與已知正確的實作比對 │
|
|
104
|
-
│ │
|
|
105
|
-
│ 變形預言(Metamorphic Oracle) │
|
|
106
|
-
│ └── 驗證輸出之間的關係 │
|
|
107
|
-
│ (例如:sort(sort(x)) == sort(x)) │
|
|
108
|
-
│ │
|
|
109
|
-
│ 統計預言 │
|
|
110
|
-
│ └── 驗證是否符合預期分布 │
|
|
111
|
-
│ │
|
|
112
|
-
│ 隱式預言 │
|
|
113
|
-
│ └── 無當機、無例外、無逾時 │
|
|
114
|
-
│ │
|
|
115
|
-
└─────────────────────────────────────────────────────────────┘
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### 測試的理論限制
|
|
119
|
-
|
|
120
|
-
> 「程式測試可以用來顯示錯誤的存在,但永遠無法證明錯誤不存在。」— Edsger W. Dijkstra
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
124
|
-
│ 測試限制 │
|
|
125
|
-
├─────────────────────────────────────────────────────────────┤
|
|
126
|
-
│ │
|
|
127
|
-
│ 窮盡測試不可能 │
|
|
128
|
-
│ ├── 無限的輸入領域 │
|
|
129
|
-
│ ├── 狀態空間爆炸 │
|
|
130
|
-
│ └── 時序和並行變化 │
|
|
131
|
-
│ │
|
|
132
|
-
│ 不可行路徑 │
|
|
133
|
-
│ ├── 某些程式碼路徑無法被任何輸入執行 │
|
|
134
|
-
│ ├── 死碼可能在控制流程圖中看起來可達 │
|
|
135
|
-
│ └── 100% 路徑覆蓋可能在數學上不可能 │
|
|
136
|
-
│ │
|
|
137
|
-
│ 停機問題 │
|
|
138
|
-
│ └── 無法透過演算法判斷所有測試是否會終止 │
|
|
139
|
-
│ │
|
|
140
|
-
│ 啟示: │
|
|
141
|
-
│ • 測試是抽樣,不是證明 │
|
|
142
|
-
│ • 風險導向的優先排序至關重要 │
|
|
143
|
-
│ • 在關鍵處結合測試與形式方法 │
|
|
144
|
-
│ │
|
|
145
|
-
└─────────────────────────────────────────────────────────────┘
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### 可測試性
|
|
149
|
-
|
|
150
|
-
可測試性衡量軟體能被有效測試的容易程度。
|
|
151
|
-
|
|
152
|
-
| 因素 | 描述 | 如何改善 |
|
|
153
|
-
|------|------|----------|
|
|
154
|
-
| **可控制性** | 設定系統狀態進行測試的能力 | 提供測試掛鉤、依賴注入 |
|
|
155
|
-
| **可觀察性** | 觀察測試結果的能力 | 增加日誌、暴露內部狀態 |
|
|
156
|
-
| **可隔離性** | 獨立測試元件的能力 | 模組化設計、清晰介面 |
|
|
157
|
-
| **可理解性** | 預期行為的清晰度 | 良好文件、清晰規格 |
|
|
158
|
-
| **穩定性** | 低變更率 | 測試階段前凍結功能 |
|
|
159
|
-
| **簡單性** | 低複雜度 | 降低循環複雜度 |
|
|
160
|
-
|
|
161
|
-
### 測試充分性準則
|
|
162
|
-
|
|
163
|
-
測試充分性準則回答:「我們測試得夠了嗎?」
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
167
|
-
│ 測試充分性準則 │
|
|
168
|
-
├─────────────────────────────────────────────────────────────┤
|
|
169
|
-
│ │
|
|
170
|
-
│ 覆蓋率準則 │
|
|
171
|
-
│ ├── 敘述覆蓋率:執行的敘述百分比 │
|
|
172
|
-
│ ├── 分支覆蓋率:走過的分支百分比 │
|
|
173
|
-
│ ├── 條件覆蓋率:評估的條件百分比 │
|
|
174
|
-
│ └── MC/DC:修改條件/決策覆蓋 │
|
|
175
|
-
│ │
|
|
176
|
-
│ 缺陷準則 │
|
|
177
|
-
│ ├── 變異分數:殺死的變異體百分比 │
|
|
178
|
-
│ └── 缺陷植入:找到的植入缺陷百分比 │
|
|
179
|
-
│ │
|
|
180
|
-
│ 需求準則 │
|
|
181
|
-
│ └── 需求覆蓋率:測試的需求百分比 │
|
|
182
|
-
│ │
|
|
183
|
-
│ 風險準則 │
|
|
184
|
-
│ └── 風險覆蓋率:測試的高風險項目百分比 │
|
|
185
|
-
│ │
|
|
186
|
-
│ 停止規則: │
|
|
187
|
-
│ • 達到目標覆蓋率 │
|
|
188
|
-
│ • 缺陷發現率降至閾值以下 │
|
|
189
|
-
│ • 預算/時間用盡(需記錄風險) │
|
|
190
|
-
│ │
|
|
191
|
-
└─────────────────────────────────────────────────────────────┘
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## 測試框架選擇
|
|
197
|
-
|
|
198
|
-
根據專案需求選擇測試框架。本標準支援兩種方法:
|
|
199
|
-
|
|
200
|
-
### 選項 A:ISTQB 標準框架
|
|
201
|
-
|
|
202
|
-
最適合企業專案、認證需求和正式 QA 流程。
|
|
203
|
-
|
|
204
|
-
**參考來源**: [ISTQB Glossary v4.0](https://glossary.istqb.org)
|
|
205
|
-
|
|
206
|
-
| 層級 | 縮寫 | 目的 |
|
|
25
|
+
| 縮寫 | 全稱 | 說明 |
|
|
207
26
|
|------|------|------|
|
|
208
|
-
|
|
|
209
|
-
|
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
- 需要認證或合規的專案
|
|
216
|
-
- 擁有專門 QA 團隊的組織
|
|
217
|
-
- 需要嚴格稽核紀錄的專案
|
|
218
|
-
|
|
219
|
-
### 選項 B:業界測試金字塔
|
|
220
|
-
|
|
221
|
-
最適合敏捷開發、CI/CD 優化和快速迭代。
|
|
222
|
-
|
|
223
|
-
**參考來源**: [Martin Fowler's Testing Pyramid](https://martinfowler.com/bliki/TestPyramid.html), [Google Testing Blog](https://testing.googleblog.com)
|
|
224
|
-
|
|
225
|
-
| 層級 | 縮寫 | 比例 | 目的 |
|
|
226
|
-
|------|------|------|------|
|
|
227
|
-
| 單元測試 | UT | 70% | 隔離元件測試 |
|
|
228
|
-
| 整合測試 | IT/SIT* | 20% | 元件互動測試 |
|
|
229
|
-
| E2E 測試 | E2E | 10% | 使用者工作流程測試 |
|
|
27
|
+
| **UT** | 單元測試 (Unit Testing) | 隔離測試個別函式/方法 |
|
|
28
|
+
| **IT** | 整合測試 (Integration Testing) | 測試元件之間的互動 |
|
|
29
|
+
| **ST** | 系統測試 (System Testing) | 測試完整整合的系統 |
|
|
30
|
+
| **AT** | 驗收測試 (Acceptance Testing) | 針對業務驗收標準進行測試 |
|
|
31
|
+
| **E2E** | 端對端測試 (End-to-End Testing) | 測試完整的使用者工作流程 |
|
|
32
|
+
| **UAT** | 使用者驗收測試 (User Acceptance Testing) | 由最終使用者執行的驗收測試 |
|
|
33
|
+
| **SIT** | 系統整合測試 (System Integration Testing) | 測試多個系統的整合 |
|
|
230
34
|
|
|
231
|
-
|
|
232
|
-
- **IT** (Integration Testing):敏捷/DevOps 社群常用
|
|
233
|
-
- **SIT** (System Integration Testing):企業/ISTQB 環境常用
|
|
234
|
-
- 兩個術語指的是同一個測試層級
|
|
235
|
-
|
|
236
|
-
**何時選擇業界金字塔**:
|
|
237
|
-
- 敏捷/Scrum 開發團隊
|
|
238
|
-
- CI/CD 導向環境
|
|
239
|
-
- 快速迭代的中小型專案
|
|
240
|
-
- DevOps 實踐
|
|
35
|
+
> **注意**:本文件中的「IT」一律指「整合測試 (Integration Testing)」,而非「資訊科技 (Information Technology)」。
|
|
241
36
|
|
|
242
37
|
---
|
|
243
38
|
|
|
244
|
-
##
|
|
39
|
+
## 測試金字塔 (預設比例)
|
|
245
40
|
|
|
246
41
|
```
|
|
247
42
|
┌─────────┐
|
|
248
|
-
│ E2E │ ← 10
|
|
249
|
-
│ 端對端 │
|
|
43
|
+
│ E2E │ ← 10% (較少,較慢,成本較高)
|
|
250
44
|
─┴─────────┴─
|
|
251
45
|
┌─────────────┐
|
|
252
|
-
│
|
|
253
|
-
│ 整合測試 │
|
|
46
|
+
│ IT/SIT │ ← 20% (整合測試)
|
|
254
47
|
─┴─────────────┴─
|
|
255
48
|
┌─────────────────┐
|
|
256
|
-
│ UT │ ← 70
|
|
257
|
-
│ 單元測試 │
|
|
49
|
+
│ UT │ ← 70% (單元測試 - 基礎)
|
|
258
50
|
└─────────────────┘
|
|
259
51
|
```
|
|
260
52
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
|
264
|
-
|
|
265
|
-
|
|
|
266
|
-
| 整合測試 | IT/SIT | 20% | 總計 < 30 分鐘 |
|
|
267
|
-
| E2E 測試 | E2E | 10% | 總計 < 2 小時 |
|
|
268
|
-
|
|
269
|
-
### ISTQB 4 層結構(替代方案)
|
|
270
|
-
|
|
271
|
-
| 層級 | 縮寫 | 執行者 | 重點 |
|
|
272
|
-
|------|------|--------|------|
|
|
273
|
-
| 單元測試 | UT | 開發人員 | 程式碼正確性 |
|
|
274
|
-
| 整合測試 | IT/SIT | 開發人員/QA | 介面契約 |
|
|
275
|
-
| 系統測試 | ST | QA 團隊 | 需求驗證 |
|
|
276
|
-
| 驗收測試 | AT/UAT | 終端使用者 | 業務驗證 |
|
|
53
|
+
| 層級 | 比例 | 執行時間目標 |
|
|
54
|
+
|------|------|--------------|
|
|
55
|
+
| 單元測試 (UT) | 70% | 總計 < 10 分鐘 |
|
|
56
|
+
| 整合測試 (IT) | 20% | 總計 < 30 分鐘 |
|
|
57
|
+
| E2E 測試 | 10% | 總計 < 2 小時 |
|
|
277
58
|
|
|
278
59
|
---
|
|
279
60
|
|
|
280
|
-
##
|
|
61
|
+
## 測試層級需求
|
|
281
62
|
|
|
282
|
-
###
|
|
63
|
+
### 單元測試 (UT)
|
|
283
64
|
|
|
284
|
-
|
|
65
|
+
**特性**: 隔離、快速 (< 100ms/個)、確定性
|
|
285
66
|
|
|
286
|
-
|
|
67
|
+
#### 範圍
|
|
287
68
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
┌─────────────────────────────────────────┐
|
|
296
|
-
│ 測試單元範圍 │
|
|
297
|
-
├─────────────────────────────────────────┤
|
|
298
|
-
│ ✅ 單一函式/方法 │
|
|
299
|
-
│ ✅ 單一類別 │
|
|
300
|
-
│ ✅ 純業務邏輯 │
|
|
301
|
-
│ ✅ 資料轉換 │
|
|
302
|
-
│ ✅ 驗證規則 │
|
|
303
|
-
├─────────────────────────────────────────┤
|
|
304
|
-
│ ❌ 資料庫查詢 │
|
|
305
|
-
│ ❌ 外部 API 呼叫 │
|
|
306
|
-
│ ❌ 檔案 I/O 操作 │
|
|
307
|
-
│ ❌ 多類別互動 │
|
|
308
|
-
└─────────────────────────────────────────┘
|
|
309
|
-
```
|
|
69
|
+
| 包含 | 排除 |
|
|
70
|
+
|------|------|
|
|
71
|
+
| 單一函式/方法 | 資料庫查詢 |
|
|
72
|
+
| 單一類別 | 外部 API 呼叫 |
|
|
73
|
+
| 純業務邏輯 | 檔案 I/O 操作 |
|
|
74
|
+
| 資料轉換 | 多類別互動 |
|
|
75
|
+
| 驗證規則 | 網路呼叫 |
|
|
310
76
|
|
|
311
|
-
|
|
77
|
+
#### 命名慣例
|
|
312
78
|
|
|
313
79
|
**檔案命名**:
|
|
314
80
|
```
|
|
315
|
-
[ClassName]Tests.[ext]
|
|
316
|
-
[ClassName].test.[ext]
|
|
317
|
-
[
|
|
318
|
-
|
|
319
|
-
範例:
|
|
320
|
-
UserService.test.ts
|
|
321
|
-
UserServiceTests.cs
|
|
322
|
-
user_service_test.py
|
|
323
|
-
user_service_test.go
|
|
81
|
+
[ClassName]Tests.[ext] # C#
|
|
82
|
+
[ClassName].test.[ext] # TypeScript/JavaScript
|
|
83
|
+
[class_name]_test.[ext] # Python, Go
|
|
324
84
|
```
|
|
325
85
|
|
|
326
|
-
|
|
327
|
-
```
|
|
328
|
-
[MethodName]_[Scenario]_[ExpectedResult]
|
|
329
|
-
should_[ExpectedBehavior]_when_[Condition]
|
|
330
|
-
test_[method]_[scenario]_[expected]
|
|
331
|
-
|
|
332
|
-
範例:
|
|
333
|
-
CalculateTotal_WithDiscount_ReturnsDiscountedPrice()
|
|
334
|
-
should_return_null_when_user_not_found()
|
|
335
|
-
test_validate_email_invalid_format_returns_false()
|
|
336
|
-
```
|
|
86
|
+
**方法命名** (每個專案擇一):
|
|
337
87
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
|
341
|
-
|
|
342
|
-
|
|
|
343
|
-
| 分支覆蓋率 | 60% | 80% |
|
|
344
|
-
| 函式覆蓋率 | 80% | 90% |
|
|
345
|
-
|
|
346
|
-
### 範例
|
|
347
|
-
|
|
348
|
-
```csharp
|
|
349
|
-
// C# 範例
|
|
350
|
-
[TestClass]
|
|
351
|
-
public class UserValidatorTests
|
|
352
|
-
{
|
|
353
|
-
private UserValidator _validator;
|
|
354
|
-
|
|
355
|
-
[TestInitialize]
|
|
356
|
-
public void Setup()
|
|
357
|
-
{
|
|
358
|
-
_validator = new UserValidator();
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
[TestMethod]
|
|
362
|
-
public void ValidateEmail_ValidFormat_ReturnsTrue()
|
|
363
|
-
{
|
|
364
|
-
// Arrange - 準備
|
|
365
|
-
var email = "user@example.com";
|
|
366
|
-
|
|
367
|
-
// Act - 執行
|
|
368
|
-
var result = _validator.ValidateEmail(email);
|
|
369
|
-
|
|
370
|
-
// Assert - 斷言
|
|
371
|
-
Assert.IsTrue(result);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
[TestMethod]
|
|
375
|
-
public void ValidateEmail_InvalidFormat_ReturnsFalse()
|
|
376
|
-
{
|
|
377
|
-
// Arrange
|
|
378
|
-
var email = "invalid-email";
|
|
379
|
-
|
|
380
|
-
// Act
|
|
381
|
-
var result = _validator.ValidateEmail(email);
|
|
382
|
-
|
|
383
|
-
// Assert
|
|
384
|
-
Assert.IsFalse(result);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
```
|
|
88
|
+
| 風格 | 最適合 | 範例 |
|
|
89
|
+
|------|--------|------|
|
|
90
|
+
| `[Method]_[Scenario]_[Result]` | C#, Java | `CalculateTotal_NegativePrice_ThrowsException()` |
|
|
91
|
+
| `should_[behavior]_when_[condition]` | JavaScript/TypeScript | `should_reject_login_when_account_locked()` |
|
|
92
|
+
| `test_[method]_[scenario]_[expected]` | Python (pytest) | `test_validate_email_invalid_format_returns_false()` |
|
|
388
93
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
describe('validateEmail', () => {
|
|
399
|
-
it('有效的 email 格式應回傳 true', () => {
|
|
400
|
-
const result = validator.validateEmail('user@example.com');
|
|
401
|
-
expect(result).toBe(true);
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
it('無效的 email 格式應回傳 false', () => {
|
|
405
|
-
const result = validator.validateEmail('invalid-email');
|
|
406
|
-
expect(result).toBe(false);
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
```
|
|
94
|
+
#### 覆蓋率閾值
|
|
95
|
+
|
|
96
|
+
| 指標 | 最低 | 推薦 |
|
|
97
|
+
|------|------|------|
|
|
98
|
+
| 行覆蓋率 (Line) | 70% | 85% |
|
|
99
|
+
| 分支覆蓋率 (Branch) | 60% | 80% |
|
|
100
|
+
| 函式覆蓋率 (Function) | 80% | 90% |
|
|
411
101
|
|
|
412
102
|
---
|
|
413
103
|
|
|
414
|
-
|
|
104
|
+
### 整合測試 (IT)
|
|
415
105
|
|
|
416
|
-
|
|
106
|
+
**特性**: 元件整合、真實相依性 (通常容器化)、1-10 秒/個
|
|
417
107
|
|
|
418
|
-
|
|
108
|
+
#### 何時必須有整合測試
|
|
419
109
|
|
|
420
|
-
|
|
110
|
+
**決策規則**: 如果你的單元測試對查詢/過濾參數使用萬用匹配器 (`any()`, `It.IsAny<>`, `Arg.Any<>`),該功能必須有整合測試。
|
|
421
111
|
|
|
422
112
|
| 情境 | 原因 |
|
|
423
113
|
|------|------|
|
|
424
|
-
|
|
|
114
|
+
| 查詢述詞 | Mock 無法驗證過濾表達式 |
|
|
425
115
|
| 實體關聯 | 驗證外鍵正確性 |
|
|
426
|
-
| 複合主鍵 |
|
|
427
|
-
|
|
|
428
|
-
| 分頁 |
|
|
116
|
+
| 複合主鍵 | 記憶體資料庫可能與真實 DB 不同 |
|
|
117
|
+
| 欄位對應 | DTO ↔ Entity 轉換 |
|
|
118
|
+
| 分頁 | 資料排序和計數 |
|
|
429
119
|
| 交易 | 回滾行為 |
|
|
430
120
|
|
|
431
|
-
|
|
432
|
-
如果你的單元測試對查詢/過濾參數使用萬用匹配器(`any()`、`It.IsAny<>`、`Arg.Any<>`),該功能必須有整合測試。
|
|
433
|
-
|
|
434
|
-
### 特性
|
|
435
|
-
|
|
436
|
-
- **元件整合**: 測試模組邊界
|
|
437
|
-
- **真實相依性**: 使用實際資料庫、API(通常容器化)
|
|
438
|
-
- **較慢**: 每個測試通常 1-10 秒
|
|
439
|
-
|
|
440
|
-
### 範圍
|
|
121
|
+
#### 範圍
|
|
441
122
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
│ ✅ Service + Repository │
|
|
449
|
-
│ ✅ API 端點 + Service 層 │
|
|
450
|
-
│ ✅ 訊息佇列生產者/消費者 │
|
|
451
|
-
│ ✅ 快取讀寫操作 │
|
|
452
|
-
├─────────────────────────────────────────┤
|
|
453
|
-
│ ❌ 完整使用者工作流程 │
|
|
454
|
-
│ ❌ 跨服務通訊 │
|
|
455
|
-
│ ❌ UI 互動 │
|
|
456
|
-
└─────────────────────────────────────────┘
|
|
457
|
-
```
|
|
123
|
+
| 包含 | 排除 |
|
|
124
|
+
|------|------|
|
|
125
|
+
| 資料庫 CRUD 操作 | 完整使用者工作流程 |
|
|
126
|
+
| Repository + Database | 跨服務通訊 |
|
|
127
|
+
| Service + Repository | UI 互動 |
|
|
128
|
+
| API 端點 + Service 層 | |
|
|
458
129
|
|
|
459
|
-
|
|
130
|
+
#### 命名慣例
|
|
460
131
|
|
|
461
|
-
**檔案命名**:
|
|
462
132
|
```
|
|
463
133
|
[ComponentName]IntegrationTests.[ext]
|
|
464
134
|
[ComponentName].integration.test.[ext]
|
|
465
135
|
[ComponentName].itest.[ext]
|
|
466
|
-
|
|
467
|
-
範例:
|
|
468
|
-
UserRepositoryIntegrationTests.cs
|
|
469
|
-
user-service.integration.test.ts
|
|
470
|
-
user_repository_itest.py
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
**方法命名**:
|
|
474
|
-
```
|
|
475
|
-
[Operation]_[Context]_[ExpectedOutcome]
|
|
476
|
-
|
|
477
|
-
範例:
|
|
478
|
-
CreateUser_WithValidData_PersistsToDatabase()
|
|
479
|
-
GetUserById_ExistingUser_ReturnsUserFromDatabase()
|
|
480
|
-
SendMessage_ToQueue_ConsumerReceivesMessage()
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### 測試夾具
|
|
484
|
-
|
|
485
|
-
```csharp
|
|
486
|
-
// C# 整合測試範例,使用測試資料庫
|
|
487
|
-
[TestClass]
|
|
488
|
-
public class UserRepositoryIntegrationTests
|
|
489
|
-
{
|
|
490
|
-
private TestDbContext _dbContext;
|
|
491
|
-
private UserRepository _repository;
|
|
492
|
-
|
|
493
|
-
[TestInitialize]
|
|
494
|
-
public async Task Setup()
|
|
495
|
-
{
|
|
496
|
-
// 使用測試資料庫(如 SQLite in-memory 或 Testcontainers)
|
|
497
|
-
_dbContext = TestDbContextFactory.Create();
|
|
498
|
-
_repository = new UserRepository(_dbContext);
|
|
499
|
-
await _dbContext.Database.EnsureCreatedAsync();
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
[TestCleanup]
|
|
503
|
-
public async Task Cleanup()
|
|
504
|
-
{
|
|
505
|
-
await _dbContext.DisposeAsync();
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
[TestMethod]
|
|
509
|
-
public async Task CreateUser_WithValidData_PersistsToDatabase()
|
|
510
|
-
{
|
|
511
|
-
// Arrange - 準備
|
|
512
|
-
var user = new User { Name = "Test User", Email = "test@example.com" };
|
|
513
|
-
|
|
514
|
-
// Act - 執行
|
|
515
|
-
await _repository.CreateAsync(user);
|
|
516
|
-
var savedUser = await _repository.GetByIdAsync(user.Id);
|
|
517
|
-
|
|
518
|
-
// Assert - 斷言
|
|
519
|
-
Assert.IsNotNull(savedUser);
|
|
520
|
-
Assert.AreEqual("Test User", savedUser.Name);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
136
|
```
|
|
524
137
|
|
|
525
138
|
---
|
|
526
139
|
|
|
527
|
-
|
|
140
|
+
### 端對端測試 (E2E)
|
|
528
141
|
|
|
529
|
-
|
|
142
|
+
**特性**: 使用者視角、全端 (UI → API → Database)、最慢 (30s+/個)
|
|
530
143
|
|
|
531
|
-
|
|
144
|
+
#### 範圍
|
|
532
145
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
- **完整系統**: 所有元件部署並整合
|
|
536
|
-
- **基於需求**: 依據功能規格測試
|
|
537
|
-
- **類生產環境**: 使用類似生產的環境
|
|
538
|
-
|
|
539
|
-
### 範圍
|
|
540
|
-
|
|
541
|
-
```
|
|
542
|
-
┌─────────────────────────────────────────┐
|
|
543
|
-
│ 系統測試範圍 │
|
|
544
|
-
├─────────────────────────────────────────┤
|
|
545
|
-
│ ✅ 完整 API 工作流程 │
|
|
546
|
-
│ ✅ 跨服務交易 │
|
|
547
|
-
│ ✅ 資料流貫穿整個系統 │
|
|
548
|
-
│ ✅ 安全需求 │
|
|
549
|
-
│ ✅ 負載下的效能 │
|
|
550
|
-
│ ✅ 錯誤處理與恢復 │
|
|
551
|
-
│ ✅ 設定驗證 │
|
|
552
|
-
├─────────────────────────────────────────┤
|
|
553
|
-
│ ❌ UI 視覺測試 │
|
|
554
|
-
│ ❌ 使用者流程模擬 │
|
|
555
|
-
│ ❌ A/B 測試情境 │
|
|
556
|
-
└─────────────────────────────────────────┘
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
### 系統測試類型
|
|
560
|
-
|
|
561
|
-
| 類型 | 說明 |
|
|
146
|
+
| 包含 | 排除 |
|
|
562
147
|
|------|------|
|
|
563
|
-
|
|
|
564
|
-
|
|
|
565
|
-
|
|
|
566
|
-
| 可靠性測試 | 故障轉移、恢復、穩定性 |
|
|
567
|
-
| 相容性測試 | 跨平台、瀏覽器相容性 |
|
|
148
|
+
| 關鍵使用者旅程 | 每個可能的使用者路徑 |
|
|
149
|
+
| 登入/驗證流程 | 邊緣案例 (使用 UT/IT) |
|
|
150
|
+
| 核心業務交易 | 效能基準測試 |
|
|
568
151
|
|
|
569
|
-
|
|
152
|
+
#### 命名慣例
|
|
570
153
|
|
|
571
|
-
**檔案命名**:
|
|
572
|
-
```
|
|
573
|
-
[Feature]SystemTests.[ext]
|
|
574
|
-
[Feature].system.test.[ext]
|
|
575
|
-
[Feature]_st.[ext]
|
|
576
|
-
|
|
577
|
-
範例:
|
|
578
|
-
OrderProcessingSystemTests.cs
|
|
579
|
-
authentication.system.test.ts
|
|
580
|
-
payment_processing_st.py
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
### 範例
|
|
584
|
-
|
|
585
|
-
```csharp
|
|
586
|
-
// 系統測試範例:完整資源處理流程
|
|
587
|
-
// 注意:將 {Resource}, {Item}, {Action} 替換為您的領域概念
|
|
588
|
-
[TestClass]
|
|
589
|
-
public class ResourceProcessingSystemTests
|
|
590
|
-
{
|
|
591
|
-
private HttpClient _client;
|
|
592
|
-
private TestEnvironment _env;
|
|
593
|
-
|
|
594
|
-
[TestInitialize]
|
|
595
|
-
public async Task Setup()
|
|
596
|
-
{
|
|
597
|
-
_env = await TestEnvironment.CreateAsync();
|
|
598
|
-
_client = _env.CreateAuthenticatedClient();
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
[TestMethod]
|
|
602
|
-
public async Task ProcessResource_CompleteFlow_CompletedSuccessfully()
|
|
603
|
-
{
|
|
604
|
-
// Arrange: 建立測試資料
|
|
605
|
-
var item = await _env.CreateTestItem(value: 100);
|
|
606
|
-
var user = await _env.CreateTestUser();
|
|
607
|
-
|
|
608
|
-
// Act: 執行完整處理流程
|
|
609
|
-
// Step 1: 建立請求
|
|
610
|
-
var requestResponse = await _client.PostAsync("/api/requests",
|
|
611
|
-
new { itemId = item.Id, quantity = 2 });
|
|
612
|
-
Assert.AreEqual(HttpStatusCode.OK, requestResponse.StatusCode);
|
|
613
|
-
|
|
614
|
-
// Step 2: 提交處理
|
|
615
|
-
var processResponse = await _client.PostAsync("/api/processes",
|
|
616
|
-
new { requestId = requestResponse.RequestId, userId = user.Id });
|
|
617
|
-
var process = await processResponse.Content.ReadAsAsync<Process>();
|
|
618
|
-
Assert.AreEqual(HttpStatusCode.Created, processResponse.StatusCode);
|
|
619
|
-
|
|
620
|
-
// Step 3: 確認完成
|
|
621
|
-
var confirmResponse = await _client.PostAsync($"/api/processes/{process.Id}/confirm",
|
|
622
|
-
new { confirmationType = "standard", amount = 200 });
|
|
623
|
-
Assert.AreEqual(HttpStatusCode.OK, confirmResponse.StatusCode);
|
|
624
|
-
|
|
625
|
-
// Assert: 驗證最終狀態
|
|
626
|
-
var finalProcess = await _client.GetAsync($"/api/processes/{process.Id}");
|
|
627
|
-
var result = await finalProcess.Content.ReadAsAsync<Process>();
|
|
628
|
-
|
|
629
|
-
Assert.AreEqual(ProcessStatus.Completed, result.Status);
|
|
630
|
-
Assert.AreEqual(200, result.TotalAmount);
|
|
631
|
-
Assert.IsNotNull(result.Confirmation);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
---
|
|
637
|
-
|
|
638
|
-
## 端對端測試 (E2E)
|
|
639
|
-
|
|
640
|
-
### 定義
|
|
641
|
-
|
|
642
|
-
從使用者介面測試完整的使用者工作流程,貫穿所有系統層。
|
|
643
|
-
|
|
644
|
-
### 特性
|
|
645
|
-
|
|
646
|
-
- **使用者視角**: 模擬真實使用者互動
|
|
647
|
-
- **全棧**: UI → API → 資料庫 → 外部服務
|
|
648
|
-
- **最慢**: 每個測試通常 30 秒到數分鐘
|
|
649
|
-
|
|
650
|
-
### 範圍
|
|
651
|
-
|
|
652
|
-
```
|
|
653
|
-
┌─────────────────────────────────────────┐
|
|
654
|
-
│ E2E 測試範圍 │
|
|
655
|
-
├─────────────────────────────────────────┤
|
|
656
|
-
│ ✅ 關鍵使用者流程 │
|
|
657
|
-
│ ✅ 登入/驗證流程 │
|
|
658
|
-
│ ✅ 核心業務交易 │
|
|
659
|
-
│ ✅ 跨瀏覽器功能 │
|
|
660
|
-
│ ✅ 部署煙霧測試 │
|
|
661
|
-
├─────────────────────────────────────────┤
|
|
662
|
-
│ ❌ 所有可能的使用者路徑 │
|
|
663
|
-
│ ❌ 邊界情況(使用 UT/IT) │
|
|
664
|
-
│ ❌ 效能基準測試 │
|
|
665
|
-
└─────────────────────────────────────────┘
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
### 命名慣例
|
|
669
|
-
|
|
670
|
-
**檔案命名**:
|
|
671
154
|
```
|
|
672
155
|
[UserJourney].e2e.[ext]
|
|
673
156
|
[Feature].e2e.spec.[ext]
|
|
674
157
|
e2e/[feature]/[scenario].[ext]
|
|
675
|
-
|
|
676
|
-
範例:
|
|
677
|
-
user-registration.e2e.ts
|
|
678
|
-
checkout-flow.e2e.spec.ts
|
|
679
|
-
e2e/authentication/login.spec.ts
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
### 範例
|
|
683
|
-
|
|
684
|
-
```typescript
|
|
685
|
-
// Playwright E2E 測試範例
|
|
686
|
-
import { test, expect } from '@playwright/test';
|
|
687
|
-
|
|
688
|
-
test.describe('使用者註冊流程', () => {
|
|
689
|
-
test('應成功完成註冊並登入', async ({ page }) => {
|
|
690
|
-
// Step 1: 導航到註冊頁面
|
|
691
|
-
await page.goto('/register');
|
|
692
|
-
|
|
693
|
-
// Step 2: 填寫註冊表單
|
|
694
|
-
await page.fill('[data-testid="email"]', 'newuser@example.com');
|
|
695
|
-
await page.fill('[data-testid="password"]', 'SecurePass123!');
|
|
696
|
-
await page.fill('[data-testid="confirm-password"]', 'SecurePass123!');
|
|
697
|
-
await page.click('[data-testid="register-button"]');
|
|
698
|
-
|
|
699
|
-
// Step 3: 驗證註冊成功
|
|
700
|
-
await expect(page.locator('[data-testid="success-message"]'))
|
|
701
|
-
.toContainText('Registration successful');
|
|
702
|
-
|
|
703
|
-
// Step 4: 使用新帳號登入
|
|
704
|
-
await page.goto('/login');
|
|
705
|
-
await page.fill('[data-testid="email"]', 'newuser@example.com');
|
|
706
|
-
await page.fill('[data-testid="password"]', 'SecurePass123!');
|
|
707
|
-
await page.click('[data-testid="login-button"]');
|
|
708
|
-
|
|
709
|
-
// Step 5: 驗證登入成功並導向儀表板
|
|
710
|
-
await expect(page).toHaveURL('/dashboard');
|
|
711
|
-
await expect(page.locator('[data-testid="welcome-message"]'))
|
|
712
|
-
.toContainText('Welcome, newuser@example.com');
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
158
|
```
|
|
716
159
|
|
|
717
160
|
---
|
|
718
161
|
|
|
719
|
-
##
|
|
720
|
-
|
|
721
|
-
靜態測試在不執行軟體的情況下檢查工作產出物(程式碼、文件、需求)。它透過在 SDLC 早期發現缺陷來補充動態測試。
|
|
722
|
-
|
|
723
|
-
**參考來源**:ISTQB CTFL v4.0 第 3 章、ISO/IEC/IEEE 29119-4
|
|
724
|
-
|
|
725
|
-
### 靜態測試類型
|
|
726
|
-
|
|
727
|
-
```
|
|
728
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
729
|
-
│ 靜態測試類型 │
|
|
730
|
-
├─────────────────────────────────────────────────────────────┤
|
|
731
|
-
│ 審查(人工) │
|
|
732
|
-
│ ├── 非正式審查:臨時性、無正式流程 │
|
|
733
|
-
│ ├── 走查:作者主導、教育目的 │
|
|
734
|
-
│ ├── 技術審查:同儕主導、發現缺陷 │
|
|
735
|
-
│ └── 檢驗:正式、度量驅動、最嚴謹 │
|
|
736
|
-
├─────────────────────────────────────────────────────────────┤
|
|
737
|
-
│ 靜態分析(工具輔助) │
|
|
738
|
-
│ ├── 程式碼分析:Linters、複雜度分析器 │
|
|
739
|
-
│ ├── 安全分析:SAST 工具(SonarQube、Checkmarx) │
|
|
740
|
-
│ ├── 架構分析:相依性檢查 │
|
|
741
|
-
│ └── 資料流分析:變數使用模式 │
|
|
742
|
-
└─────────────────────────────────────────────────────────────┘
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
### 審查流程(ISTQB)
|
|
746
|
-
|
|
747
|
-
| 階段 | 活動 |
|
|
748
|
-
|------|------|
|
|
749
|
-
| 計畫 | 定義範圍、進入條件、角色 |
|
|
750
|
-
| 啟動審查 | 分發工作產出物 |
|
|
751
|
-
| 個人審查 | 每位審查者獨立檢查 |
|
|
752
|
-
| 問題溝通 | 在會議中討論發現 |
|
|
753
|
-
| 修復與報告 | 作者修復、收集指標 |
|
|
754
|
-
|
|
755
|
-
### 各語言靜態分析工具
|
|
756
|
-
|
|
757
|
-
| 語言 | Linting | 安全性 | 複雜度 |
|
|
758
|
-
|------|---------|--------|--------|
|
|
759
|
-
| JavaScript/TypeScript | ESLint, Biome | npm audit, Snyk | ESLint 複雜度規則 |
|
|
760
|
-
| Python | Pylint, Ruff, Flake8 | Bandit, Safety | Radon |
|
|
761
|
-
| Java | Checkstyle, PMD | SpotBugs, OWASP DC | JaCoCo |
|
|
762
|
-
| C# | StyleCop, Roslyn | Security Code Scan | NDepend |
|
|
763
|
-
| Go | golangci-lint | gosec | gocyclo |
|
|
764
|
-
|
|
765
|
-
### 程式碼審查檢查清單
|
|
766
|
-
|
|
767
|
-
```
|
|
768
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
769
|
-
│ 程式碼審查重點領域 │
|
|
770
|
-
├─────────────────────────────────────────────────────────────┤
|
|
771
|
-
│ 功能性 │
|
|
772
|
-
│ ├── 程式碼是否執行預期功能? │
|
|
773
|
-
│ ├── 是否處理邊界情況? │
|
|
774
|
-
│ └── 錯誤處理是否適當? │
|
|
775
|
-
├─────────────────────────────────────────────────────────────┤
|
|
776
|
-
│ 可維護性 │
|
|
777
|
-
│ ├── 程式碼是否可讀且組織良好? │
|
|
778
|
-
│ ├── 命名是否有意義? │
|
|
779
|
-
│ └── 複雜度是否可管理? │
|
|
780
|
-
├─────────────────────────────────────────────────────────────┤
|
|
781
|
-
│ 安全性 │
|
|
782
|
-
│ ├── 輸入驗證是否存在? │
|
|
783
|
-
│ ├── 沒有寫死的機密資訊? │
|
|
784
|
-
│ └── SQL 注入 / XSS 預防措施? │
|
|
785
|
-
├─────────────────────────────────────────────────────────────┤
|
|
786
|
-
│ 效能 │
|
|
787
|
-
│ ├── 沒有明顯的低效率? │
|
|
788
|
-
│ ├── 資源清理(連線、檔案)? │
|
|
789
|
-
│ └── 適當的資料結構? │
|
|
790
|
-
└─────────────────────────────────────────────────────────────┘
|
|
791
|
-
```
|
|
792
|
-
|
|
793
|
-
---
|
|
794
|
-
|
|
795
|
-
## 測試設計技術
|
|
796
|
-
|
|
797
|
-
測試設計技術是用於導出和選擇測試案例的方法。ISTQB 和 ISO/IEC/IEEE 29119 將其分為三個主要類別。
|
|
798
|
-
|
|
799
|
-
**參考來源**:ISTQB CTFL v4.0 第 4 章、ISO/IEC/IEEE 29119-4
|
|
800
|
-
|
|
801
|
-
### 技術分類
|
|
802
|
-
|
|
803
|
-
```
|
|
804
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
805
|
-
│ 測試設計技術分類 │
|
|
806
|
-
├─────────────────────────────────────────────────────────────┤
|
|
807
|
-
│ 規格導向(黑箱) │
|
|
808
|
-
│ └── 從需求/規格導出測試 │
|
|
809
|
-
├─────────────────────────────────────────────────────────────┤
|
|
810
|
-
│ 結構導向(白箱) │
|
|
811
|
-
│ └── 從內部程式碼結構導出測試 │
|
|
812
|
-
├─────────────────────────────────────────────────────────────┤
|
|
813
|
-
│ 經驗導向 │
|
|
814
|
-
│ └── 從測試人員的知識和直覺導出測試 │
|
|
815
|
-
└─────────────────────────────────────────────────────────────┘
|
|
816
|
-
```
|
|
817
|
-
|
|
818
|
-
### 規格導向技術(黑箱)
|
|
819
|
-
|
|
820
|
-
#### 1. 等價類別劃分(EP)
|
|
821
|
-
|
|
822
|
-
將輸入資料劃分為系統應該以相同方式處理的分區。
|
|
823
|
-
|
|
824
|
-
```
|
|
825
|
-
輸入:年齡(有效範圍:18-65)
|
|
826
|
-
|
|
827
|
-
┌─────────────┬─────────────┬─────────────┐
|
|
828
|
-
│ 無效 │ 有效 │ 無效 │
|
|
829
|
-
│ < 18 │ 18 - 65 │ > 65 │
|
|
830
|
-
├─────────────┼─────────────┼─────────────┤
|
|
831
|
-
│ 分區 1 │ 分區 2 │ 分區 3 │
|
|
832
|
-
│ 測試: 10 │ 測試: 30 │ 測試: 70 │
|
|
833
|
-
└─────────────┴─────────────┴─────────────┘
|
|
834
|
-
|
|
835
|
-
覆蓋率:每個分區至少 1 個測試案例
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
#### 2. 邊界值分析(BVA)
|
|
839
|
-
|
|
840
|
-
在等價類別分區的邊界進行測試,因為缺陷最可能在此發生。
|
|
841
|
-
|
|
842
|
-
```
|
|
843
|
-
輸入:數量(有效範圍:1-100)
|
|
844
|
-
|
|
845
|
-
0 1 2 ... 99 100 101
|
|
846
|
-
│ │ │ │ │ │
|
|
847
|
-
▼ ▼ ▼ ▼ ▼ ▼
|
|
848
|
-
無效 有效 有效 有效 有效 無效
|
|
849
|
-
(邊界) (邊界) (邊界) (邊界)
|
|
850
|
-
|
|
851
|
-
測試值:0, 1, 2, 99, 100, 101
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
#### 3. 決策表測試
|
|
855
|
-
|
|
856
|
-
用於捕捉具有多個條件的複雜業務規則。
|
|
857
|
-
|
|
858
|
-
```
|
|
859
|
-
折扣規則:
|
|
860
|
-
- 高級會員:20% 折扣
|
|
861
|
-
- 訂單 > $100:10% 折扣
|
|
862
|
-
- 兩個條件都符合:25% 折扣(不累加)
|
|
863
|
-
|
|
864
|
-
┌─────────────────┬──────┬──────┬──────┬──────┐
|
|
865
|
-
│ 條件 │ TC1 │ TC2 │ TC3 │ TC4 │
|
|
866
|
-
├─────────────────┼──────┼──────┼──────┼──────┤
|
|
867
|
-
│ 高級會員 │ N │ Y │ N │ Y │
|
|
868
|
-
│ 訂單 > $100 │ N │ N │ Y │ Y │
|
|
869
|
-
├─────────────────┼──────┼──────┼──────┼──────┤
|
|
870
|
-
│ 動作 │ │ │ │ │
|
|
871
|
-
├─────────────────┼──────┼──────┼──────┼──────┤
|
|
872
|
-
│ 折扣 % │ 0% │ 20% │ 10% │ 25% │
|
|
873
|
-
└─────────────────┴──────┴──────┴──────┴──────┘
|
|
874
|
-
```
|
|
875
|
-
|
|
876
|
-
#### 4. 狀態轉換測試
|
|
877
|
-
|
|
878
|
-
基於系統狀態和轉換測試行為變化。
|
|
879
|
-
|
|
880
|
-
```
|
|
881
|
-
訂單狀態機:
|
|
882
|
-
|
|
883
|
-
┌─────────┐ place() ┌───────────┐ pay() ┌────────┐
|
|
884
|
-
│ 草稿 │──────────────▶│ 待處理 │───────────▶│ 已付款 │
|
|
885
|
-
└─────────┘ └───────────┘ └────────┘
|
|
886
|
-
│ │ │
|
|
887
|
-
│ cancel() │ cancel() │ ship()
|
|
888
|
-
▼ ▼ ▼
|
|
889
|
-
┌───────────┐ ┌───────────┐ ┌──────────┐
|
|
890
|
-
│ 已取消 │ │ 已取消 │ │ 已出貨 │
|
|
891
|
-
└───────────┘ └───────────┘ └──────────┘
|
|
892
|
-
```
|
|
893
|
-
|
|
894
|
-
### 結構導向技術(白箱)
|
|
895
|
-
|
|
896
|
-
#### 1. 語句覆蓋
|
|
897
|
-
|
|
898
|
-
確保每個語句至少執行一次。
|
|
899
|
-
|
|
900
|
-
#### 2. 分支覆蓋
|
|
901
|
-
|
|
902
|
-
確保每個分支(決策結果)都被執行。
|
|
903
|
-
|
|
904
|
-
#### 3. 條件覆蓋
|
|
905
|
-
|
|
906
|
-
確保決策中的每個條件都被評估為 true 和 false。
|
|
907
|
-
|
|
908
|
-
#### 4. MC/DC(修改條件/決策覆蓋)
|
|
909
|
-
|
|
910
|
-
每個條件獨立影響決策結果。安全關鍵系統必需。
|
|
911
|
-
|
|
912
|
-
### 額外規格導向技術
|
|
913
|
-
|
|
914
|
-
#### 6. 成對測試(Pairwise Testing / 組合測試)
|
|
915
|
-
|
|
916
|
-
測試所有可能的輸入參數值配對,在維持良好覆蓋率的同時減少測試案例數量。
|
|
917
|
-
|
|
918
|
-
**參考來源**:SWEBOK v4.0 - 輸入領域技術
|
|
919
|
-
|
|
920
|
-
```
|
|
921
|
-
範例:具有 3 個參數的登入表單,每個參數有 3 個值
|
|
922
|
-
|
|
923
|
-
參數:
|
|
924
|
-
- 瀏覽器:Chrome, Firefox, Safari
|
|
925
|
-
- 作業系統:Windows, macOS, Linux
|
|
926
|
-
- 語言:英文, 西班牙文, 法文
|
|
927
|
-
|
|
928
|
-
完整組合:3 × 3 × 3 = 27 個測試案例
|
|
929
|
-
成對覆蓋:9 個測試案例(涵蓋所有配對)
|
|
930
|
-
```
|
|
931
|
-
|
|
932
|
-
**工具**:PICT(Microsoft)、AllPairs、Jenny
|
|
933
|
-
|
|
934
|
-
#### 7. 資料流測試(Data Flow Testing)
|
|
935
|
-
|
|
936
|
-
透過追蹤變數的定義和使用來測試程式中的資料流動。
|
|
937
|
-
|
|
938
|
-
**參考來源**:SWEBOK v4.0 - 程式碼導向技術
|
|
939
|
-
|
|
940
|
-
```
|
|
941
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
942
|
-
│ 資料流術語 │
|
|
943
|
-
├─────────────────────────────────────────────────────────────┤
|
|
944
|
-
│ │
|
|
945
|
-
│ Definition(定義):變數被賦值 │
|
|
946
|
-
│ Use(使用):變數的值被存取 │
|
|
947
|
-
│ - c-use:計算使用(在計算中) │
|
|
948
|
-
│ - p-use:述詞使用(在條件中) │
|
|
949
|
-
│ │
|
|
950
|
-
│ def-use 配對:從定義到使用的路徑 │
|
|
951
|
-
│ def-clear 路徑:定義和使用之間沒有重新定義 │
|
|
952
|
-
│ │
|
|
953
|
-
└─────────────────────────────────────────────────────────────┘
|
|
954
|
-
```
|
|
955
|
-
|
|
956
|
-
**覆蓋準則**:
|
|
957
|
-
|
|
958
|
-
| 準則 | 要求 | 強度 |
|
|
959
|
-
|------|------|------|
|
|
960
|
-
| All-Defs | 每個定義至少到達一個使用 | 弱 |
|
|
961
|
-
| All-Uses | 每個 def-use 配對都被執行 | 中 |
|
|
962
|
-
| All-DU-Paths | 從定義到使用的所有 def-clear 路徑 | 強 |
|
|
963
|
-
|
|
964
|
-
### 技術選擇指南
|
|
965
|
-
|
|
966
|
-
| 技術 | 最適合 | 測試層級 |
|
|
967
|
-
|------|--------|----------|
|
|
968
|
-
| 等價類別劃分 | 輸入驗證、範圍 | UT, IT |
|
|
969
|
-
| 邊界值分析 | 數值限制、日期 | UT, IT |
|
|
970
|
-
| 決策表 | 複雜業務規則 | UT, IT, ST |
|
|
971
|
-
| 狀態轉換 | 工作流程、狀態變更 | IT, ST |
|
|
972
|
-
| 用例測試 | 使用者場景 | ST, E2E |
|
|
973
|
-
| 成對測試 | 多參數組合 | IT, ST |
|
|
974
|
-
| 資料流測試 | 變數生命週期驗證 | UT |
|
|
975
|
-
| 語句覆蓋 | 基本程式碼覆蓋 | UT |
|
|
976
|
-
| 分支覆蓋 | 決策邏輯 | UT |
|
|
977
|
-
| MC/DC | 安全關鍵系統 | UT |
|
|
978
|
-
|
|
979
|
-
---
|
|
980
|
-
|
|
981
|
-
## 經驗導向測試
|
|
982
|
-
|
|
983
|
-
經驗導向測試利用測試人員的知識、技能和直覺來設計和執行測試。它補充系統化技術。
|
|
984
|
-
|
|
985
|
-
**參考來源**:ISTQB CTFL v4.0 第 4.4 節
|
|
986
|
-
|
|
987
|
-
### 經驗導向測試類型
|
|
988
|
-
|
|
989
|
-
#### 1. 探索性測試
|
|
990
|
-
|
|
991
|
-
同時進行測試設計、執行和學習。測試人員在沒有預定義腳本的情況下探索系統。
|
|
992
|
-
|
|
993
|
-
```
|
|
994
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
995
|
-
│ 探索性測試會議 │
|
|
996
|
-
├─────────────────────────────────────────────────────────────┤
|
|
997
|
-
│ 章程:"探索結帳流程,重點關注付款失敗場景" │
|
|
998
|
-
├─────────────────────────────────────────────────────────────┤
|
|
999
|
-
│ 時間箱:60 分鐘 │
|
|
1000
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1001
|
-
│ 備註: │
|
|
1002
|
-
│ - 測試過期信用卡 → 得到通用錯誤 │
|
|
1003
|
-
│ - 測試餘額不足 → 同樣的通用錯誤 │
|
|
1004
|
-
│ - 發現:不同失敗沒有特定錯誤訊息 │
|
|
1005
|
-
│ - Bug:用相同卡片重試不會清除之前的錯誤 │
|
|
1006
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1007
|
-
│ 發現的 Bug:2 個 │
|
|
1008
|
-
│ 需進一步測試的區域:錯誤訊息的具體性 │
|
|
1009
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1010
|
-
```
|
|
1011
|
-
|
|
1012
|
-
#### 2. 錯誤猜測
|
|
1013
|
-
|
|
1014
|
-
根據類似系統的經驗或常見錯誤來預測缺陷。
|
|
1015
|
-
|
|
1016
|
-
```
|
|
1017
|
-
常見錯誤類別:
|
|
1018
|
-
|
|
1019
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1020
|
-
│ 輸入錯誤 │
|
|
1021
|
-
│ ├── 空/null 輸入 │
|
|
1022
|
-
│ ├── 超長字串 │
|
|
1023
|
-
│ ├── 特殊字元(', ", <, >, & 等) │
|
|
1024
|
-
│ ├── Unicode/emoji 字元 │
|
|
1025
|
-
│ └── 期望正數時輸入負數 │
|
|
1026
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1027
|
-
│ 邊界錯誤 │
|
|
1028
|
-
│ ├── 差一錯誤 │
|
|
1029
|
-
│ ├── 整數溢位/下溢 │
|
|
1030
|
-
│ ├── 日期邊界(閏年、月底) │
|
|
1031
|
-
│ └── 陣列索引越界 │
|
|
1032
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1033
|
-
│ 狀態錯誤 │
|
|
1034
|
-
│ ├── 對已刪除記錄的操作 │
|
|
1035
|
-
│ ├── 並發修改 │
|
|
1036
|
-
│ ├── 操作期間會話超時 │
|
|
1037
|
-
│ └── 提交後按瀏覽器返回鍵 │
|
|
1038
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1039
|
-
```
|
|
1040
|
-
|
|
1041
|
-
#### 3. 檢查表測試
|
|
1042
|
-
|
|
1043
|
-
使用基於經驗和標準的預定義檢查表。
|
|
1044
|
-
|
|
1045
|
-
### 何時使用經驗導向測試
|
|
1046
|
-
|
|
1047
|
-
| 場景 | 建議技術 |
|
|
1048
|
-
|------|----------|
|
|
1049
|
-
| 新功能探索 | 探索性測試 |
|
|
1050
|
-
| 沒有文件的遺留系統 | 探索性測試 |
|
|
1051
|
-
| 已知問題區域 | 錯誤猜測 |
|
|
1052
|
-
| 回歸測試 | 檢查表測試 |
|
|
1053
|
-
| 時間壓力 / 快速驗證 | 錯誤猜測 |
|
|
1054
|
-
| 合規驗證 | 檢查表測試 |
|
|
1055
|
-
|
|
1056
|
-
---
|
|
1057
|
-
|
|
1058
|
-
## 風險導向測試
|
|
1059
|
-
|
|
1060
|
-
風險導向測試根據潛在失敗的可能性和影響來優先安排測試工作。
|
|
1061
|
-
|
|
1062
|
-
**參考來源**:ISTQB CTFL v4.0 第 5.2 節
|
|
1063
|
-
|
|
1064
|
-
### 風險評估
|
|
1065
|
-
|
|
1066
|
-
#### 風險公式
|
|
1067
|
-
|
|
1068
|
-
```
|
|
1069
|
-
風險等級 = 可能性 × 影響
|
|
1070
|
-
|
|
1071
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1072
|
-
│ 風險矩陣 │
|
|
1073
|
-
├─────────────┬───────────────────────────────────────────────┤
|
|
1074
|
-
│ │ 影響 │
|
|
1075
|
-
│ 可能性 │ 低 (1) 中 (2) 高 (3) │
|
|
1076
|
-
├─────────────┼───────────────────────────────────────────────┤
|
|
1077
|
-
│ 高 (3) │ 中 (3) 高 (6) 嚴重 (9) │
|
|
1078
|
-
│ 中 (2) │ 低 (2) 中 (4) 高 (6) │
|
|
1079
|
-
│ 低 (1) │ 低 (1) 低 (2) 中 (3) │
|
|
1080
|
-
└─────────────┴───────────────────────────────────────────────┘
|
|
1081
|
-
```
|
|
1082
|
-
|
|
1083
|
-
#### 風險因素
|
|
1084
|
-
|
|
1085
|
-
**可能性因素**(技術風險):
|
|
1086
|
-
- 功能複雜度
|
|
1087
|
-
- 新的/不熟悉的技術
|
|
1088
|
-
- 程式碼品質指標
|
|
1089
|
-
- 開發人員經驗
|
|
1090
|
-
- 變更頻率
|
|
1091
|
-
- 整合複雜度
|
|
1092
|
-
|
|
1093
|
-
**影響因素**(業務風險):
|
|
1094
|
-
- 營收影響
|
|
1095
|
-
- 受影響的使用者數量
|
|
1096
|
-
- 法規合規
|
|
1097
|
-
- 品牌聲譽
|
|
1098
|
-
- 資料安全/隱私
|
|
1099
|
-
- 營運關鍵性
|
|
1100
|
-
|
|
1101
|
-
### 風險導向測試優先排序
|
|
1102
|
-
|
|
1103
|
-
```
|
|
1104
|
-
範例:電子商務應用程式
|
|
1105
|
-
|
|
1106
|
-
┌──────────────────────┬─────────┬─────────┬───────┬──────────┐
|
|
1107
|
-
│ 功能 │ 可能性 │ 影響 │ 風險 │ 優先順序 │
|
|
1108
|
-
├──────────────────────┼─────────┼─────────┼───────┼──────────┤
|
|
1109
|
-
│ 付款處理 │ 2 │ 3 │ 6 │ 1 │
|
|
1110
|
-
│ 使用者認證 │ 2 │ 3 │ 6 │ 2 │
|
|
1111
|
-
│ 購物車 │ 2 │ 2 │ 4 │ 3 │
|
|
1112
|
-
│ 商品搜尋 │ 1 │ 2 │ 2 │ 4 │
|
|
1113
|
-
│ 商品評論 │ 1 │ 1 │ 1 │ 5 │
|
|
1114
|
-
│ 願望清單 │ 1 │ 1 │ 1 │ 6 │
|
|
1115
|
-
└──────────────────────┴─────────┴─────────┴───────┴──────────┘
|
|
1116
|
-
|
|
1117
|
-
測試工作分配:
|
|
1118
|
-
- 嚴重(風險 6+):50% 測試工作,最徹底的覆蓋
|
|
1119
|
-
- 中等(風險 3-5):30% 測試工作,標準覆蓋
|
|
1120
|
-
- 低(風險 1-2):20% 測試工作,基本覆蓋
|
|
1121
|
-
```
|
|
1122
|
-
|
|
1123
|
-
---
|
|
1124
|
-
|
|
1125
|
-
## 專項測試
|
|
1126
|
-
|
|
1127
|
-
現代軟體開發需要超越傳統類別的專項測試類型。
|
|
1128
|
-
|
|
1129
|
-
### 契約測試
|
|
1130
|
-
|
|
1131
|
-
驗證服務根據約定的契約正確通訊。對微服務架構至關重要。
|
|
1132
|
-
|
|
1133
|
-
```
|
|
1134
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1135
|
-
│ 消費者驅動契約測試 │
|
|
1136
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1137
|
-
│ │
|
|
1138
|
-
│ 消費者 提供者 │
|
|
1139
|
-
│ (前端) (API) │
|
|
1140
|
-
│ │ │ │
|
|
1141
|
-
│ │ 1. 定義期望 │ │
|
|
1142
|
-
│ │─────────────────────────────▶│ │
|
|
1143
|
-
│ │ │ │
|
|
1144
|
-
│ │ 2. 產生契約 │ │
|
|
1145
|
-
│ │ (Pact 檔案) │ │
|
|
1146
|
-
│ │ │ │
|
|
1147
|
-
│ │ 3. 分享契約 │ │
|
|
1148
|
-
│ │─────────────────────────────▶│ │
|
|
1149
|
-
│ │ │ │
|
|
1150
|
-
│ │ 4. 提供者驗證契約 │
|
|
1151
|
-
│ │ │ │
|
|
1152
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1153
|
-
```
|
|
1154
|
-
|
|
1155
|
-
**工具**:Pact、Spring Cloud Contract、Postman
|
|
1156
|
-
|
|
1157
|
-
### 變異測試
|
|
1158
|
-
|
|
1159
|
-
通過在程式碼中引入小變化(變異體)來評估測試套件品質,並檢查測試是否能檢測到它們。
|
|
1160
|
-
|
|
1161
|
-
```
|
|
1162
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1163
|
-
│ 變異測試 │
|
|
1164
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1165
|
-
│ │
|
|
1166
|
-
│ 原始程式碼: 變異體(改變運算子): │
|
|
1167
|
-
│ if (a > b) if (a >= b) ← 邊界變異 │
|
|
1168
|
-
│ if (a > b) if (a < b) ← 否定變異 │
|
|
1169
|
-
│ return a + b; return a - b; ← 算術變異 │
|
|
1170
|
-
│ return true; return false; ← 回傳值變異 │
|
|
1171
|
-
│ │
|
|
1172
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1173
|
-
│ 變異分數 = (殺死的變異體 / 總變異體) × 100 │
|
|
1174
|
-
│ │
|
|
1175
|
-
│ - 殺死:測試失敗 → 好,測試檢測到變化 │
|
|
1176
|
-
│ - 存活:測試通過 → 差,測試漏掉缺陷 │
|
|
1177
|
-
│ │
|
|
1178
|
-
│ 目標:關鍵程式碼 > 80% 變異分數 │
|
|
1179
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1180
|
-
```
|
|
1181
|
-
|
|
1182
|
-
**工具**:Stryker (JS/TS)、PITest (Java)、mutmut (Python)
|
|
1183
|
-
|
|
1184
|
-
### 混沌工程
|
|
1185
|
-
|
|
1186
|
-
通過在生產或預備環境中注入失敗來主動測試系統韌性。
|
|
1187
|
-
|
|
1188
|
-
```
|
|
1189
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1190
|
-
│ 混沌工程原則 │
|
|
1191
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1192
|
-
│ │
|
|
1193
|
-
│ 1. 定義「穩態」(正常行為指標) │
|
|
1194
|
-
│ 2. 假設在混沌期間穩態繼續維持 │
|
|
1195
|
-
│ 3. 引入真實世界事件: │
|
|
1196
|
-
│ - 伺服器故障 │
|
|
1197
|
-
│ - 網路延遲/分區 │
|
|
1198
|
-
│ - 資源耗盡 │
|
|
1199
|
-
│ - 時鐘偏移 │
|
|
1200
|
-
│ 4. 嘗試證偽假設 │
|
|
1201
|
-
│ 5. 最小化影響範圍(從小處開始) │
|
|
1202
|
-
│ │
|
|
1203
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1204
|
-
```
|
|
1205
|
-
|
|
1206
|
-
**工具**:Chaos Monkey、Gremlin、Litmus、Chaos Toolkit
|
|
1207
|
-
|
|
1208
|
-
### 額外專項測試類型(SWEBOK)
|
|
1209
|
-
|
|
1210
|
-
以下測試類型定義於 SWEBOK v4.0 作為測試目標:
|
|
1211
|
-
|
|
1212
|
-
#### 安裝測試(Installation Testing)
|
|
1213
|
-
|
|
1214
|
-
驗證軟體在目標環境中正確安裝。
|
|
1215
|
-
|
|
1216
|
-
| 階段 | 檢查項目 |
|
|
1217
|
-
|------|----------|
|
|
1218
|
-
| 安裝前 | 先決條件、磁碟空間、權限 |
|
|
1219
|
-
| 安裝過程 | 全新安裝、升級、自訂選項、靜默安裝 |
|
|
1220
|
-
| 安裝後 | 應用程式啟動、配置檔案、解除安裝 |
|
|
1221
|
-
|
|
1222
|
-
#### Alpha 和 Beta 測試
|
|
1223
|
-
|
|
1224
|
-
| 階段 | 參與者 | 環境 | 目的 |
|
|
1225
|
-
|------|--------|------|------|
|
|
1226
|
-
| **Alpha** | 內部使用者、開發人員 | 開發現場 | 早期驗證、重大問題 |
|
|
1227
|
-
| **Beta** | 外部使用者、客戶 | 客戶現場 | 真實世界驗證、回饋 |
|
|
1228
|
-
| **開放 Beta** | 一般大眾 | 各種環境 | 廣泛曝光、壓力測試 |
|
|
1229
|
-
|
|
1230
|
-
#### 復原測試(Recovery Testing)
|
|
1231
|
-
|
|
1232
|
-
測試系統從失效中復原的能力。
|
|
1233
|
-
|
|
1234
|
-
| 場景 | 測試項目 |
|
|
1235
|
-
|------|----------|
|
|
1236
|
-
| 硬體故障 | 交易期間斷電、磁碟故障、網路中斷 |
|
|
1237
|
-
| 軟體故障 | 應用程式當機復原、資料庫連線遺失 |
|
|
1238
|
-
| 資料復原 | 備份還原、交易回滾、時間點復原 |
|
|
1239
|
-
|
|
1240
|
-
**關鍵指標**:
|
|
1241
|
-
- RTO(復原時間目標):最大可接受停機時間
|
|
1242
|
-
- RPO(復原點目標):最大可接受資料遺失
|
|
1243
|
-
|
|
1244
|
-
#### 配置測試(Configuration Testing)
|
|
1245
|
-
|
|
1246
|
-
在不同配置下測試系統。測試每個支援的配置組合。
|
|
1247
|
-
|
|
1248
|
-
#### 背對背測試(Back-to-Back Testing)
|
|
1249
|
-
|
|
1250
|
-
使用相同輸入比較多個實作的輸出。
|
|
1251
|
-
|
|
1252
|
-
使用情境:
|
|
1253
|
-
- 比較新版本與舊版本
|
|
1254
|
-
- 比較最佳化程式碼與參考實作
|
|
1255
|
-
- 跨平台一致性驗證
|
|
1256
|
-
- 驗證重構程式碼行為
|
|
1257
|
-
|
|
1258
|
-
#### 易用性測試(Usability Testing)
|
|
1259
|
-
|
|
1260
|
-
評估使用者學習和使用系統的容易程度。
|
|
1261
|
-
|
|
1262
|
-
| 方法類別 | 方法 |
|
|
1263
|
-
|----------|------|
|
|
1264
|
-
| 觀察法 | 有聲思考、眼球追蹤、錄影 |
|
|
1265
|
-
| 任務法 | 任務完成率、任務時間、錯誤率 |
|
|
1266
|
-
| 問卷法 | SUS(系統易用性量表)、NPS |
|
|
1267
|
-
|
|
1268
|
-
### 專項測試總結
|
|
162
|
+
## 測試替身 (Test Doubles)
|
|
1269
163
|
|
|
1270
164
|
| 類型 | 目的 | 何時使用 |
|
|
1271
165
|
|------|------|----------|
|
|
1272
|
-
|
|
|
1273
|
-
|
|
|
1274
|
-
|
|
|
1275
|
-
|
|
|
1276
|
-
|
|
|
1277
|
-
| 無障礙測試 | 包容性設計 | 所有面向使用者的應用 |
|
|
1278
|
-
| 安裝測試 | 部署驗證 | 發布候選版本 |
|
|
1279
|
-
| Alpha/Beta 測試 | 早期使用者驗證 | 預發布階段 |
|
|
1280
|
-
| 復原測試 | 失效復原 | 業務關鍵系統 |
|
|
1281
|
-
| 配置測試 | 多配置支援 | 跨平台應用 |
|
|
1282
|
-
| 背對背測試 | 版本比較 | 遷移、重構 |
|
|
1283
|
-
| 易用性測試 | 使用者體驗 | 面向使用者的應用 |
|
|
1284
|
-
|
|
1285
|
-
---
|
|
1286
|
-
|
|
1287
|
-
## 測試相關度量
|
|
1288
|
-
|
|
1289
|
-
用於評估被測軟體和測試品質的量化度量。
|
|
1290
|
-
|
|
1291
|
-
**參考來源**:SWEBOK v4.0 第 5.4 節
|
|
1292
|
-
|
|
1293
|
-
### 程式評估度量
|
|
1294
|
-
|
|
1295
|
-
#### 缺陷密度
|
|
1296
|
-
|
|
1297
|
-
```
|
|
1298
|
-
缺陷密度 = 總缺陷數 / 大小
|
|
1299
|
-
|
|
1300
|
-
其中大小可以是:
|
|
1301
|
-
- KLOC(千行程式碼)
|
|
1302
|
-
- 功能點
|
|
1303
|
-
- 故事點
|
|
1304
|
-
|
|
1305
|
-
業界基準:
|
|
1306
|
-
┌─────────────────────┬────────────────────────────┐
|
|
1307
|
-
│ 品質等級 │ 每 KLOC 缺陷數 │
|
|
1308
|
-
├─────────────────────┼────────────────────────────┤
|
|
1309
|
-
│ 一般 │ 1 - 25 │
|
|
1310
|
-
│ 良好 │ 0.5 - 1 │
|
|
1311
|
-
│ 優秀 │ < 0.5 │
|
|
1312
|
-
│ 安全關鍵 │ < 0.1 │
|
|
1313
|
-
└─────────────────────┴────────────────────────────┘
|
|
1314
|
-
```
|
|
1315
|
-
|
|
1316
|
-
#### 可靠度成長模型
|
|
1317
|
-
|
|
1318
|
-
追蹤缺陷發現率隨時間的變化,以預測剩餘缺陷。
|
|
1319
|
-
|
|
1320
|
-
隨著測試進行:
|
|
1321
|
-
- 缺陷發現率下降
|
|
1322
|
-
- 曲線接近漸近線(總缺陷數)
|
|
1323
|
-
- 可估計剩餘缺陷
|
|
1324
|
-
|
|
1325
|
-
常見模型:Goel-Okumoto(指數型)、Musa(對數型)
|
|
1326
|
-
|
|
1327
|
-
### 測試評估度量
|
|
1328
|
-
|
|
1329
|
-
#### 缺陷植入(Fault Seeding)
|
|
1330
|
-
|
|
1331
|
-
插入已知缺陷以衡量測試效能。
|
|
1332
|
-
|
|
1333
|
-
```
|
|
1334
|
-
缺陷偵測效能 = 找到的植入缺陷 / 總植入缺陷
|
|
1335
|
-
|
|
1336
|
-
若測試找到 80% 的植入缺陷,可估計:
|
|
1337
|
-
- 對真實缺陷有類似的偵測率
|
|
1338
|
-
- 剩餘缺陷 ≈ 找到的缺陷 / 偵測率
|
|
1339
|
-
```
|
|
1340
|
-
|
|
1341
|
-
#### 覆蓋率度量摘要
|
|
1342
|
-
|
|
1343
|
-
| 度量 | 公式 | 目標 |
|
|
1344
|
-
|------|------|------|
|
|
1345
|
-
| 語句覆蓋率 | 執行的語句 / 總語句 | ≥ 70% |
|
|
1346
|
-
| 分支覆蓋率 | 執行的分支 / 總分支 | ≥ 60% |
|
|
1347
|
-
| 條件覆蓋率 | 評估 T 和 F 的條件 / 總條件 | ≥ 80% |
|
|
1348
|
-
| MC/DC | 獨立影響決策的條件 | 100%(安全關鍵)|
|
|
1349
|
-
| 需求覆蓋率 | 測試的需求 / 總需求 | 100% |
|
|
1350
|
-
| 變異分數 | 殺死的變異體 / 總變異體 | ≥ 80% |
|
|
166
|
+
| **Stub** | 回傳預定義值 | 固定的 API 回應 |
|
|
167
|
+
| **Mock** | 驗證互動 | 驗證方法被呼叫 |
|
|
168
|
+
| **Fake** | 簡化的實作 | 記憶體資料庫 |
|
|
169
|
+
| **Spy** | 記錄呼叫 | 部分 Mock |
|
|
170
|
+
| **Dummy** | 佔位符 | 填補必要參數 |
|
|
1351
171
|
|
|
1352
|
-
###
|
|
172
|
+
### 依測試層級使用
|
|
1353
173
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
│ 效率度量 │
|
|
1360
|
-
│ ├── 測試案例生產力 = 建立的測試 / 投入 │
|
|
1361
|
-
│ ├── 缺陷偵測率 = 找到的缺陷 / 測試時數 │
|
|
1362
|
-
│ └── 自動化率 = 自動化測試 / 總測試 │
|
|
1363
|
-
│ │
|
|
1364
|
-
│ 效能度量 │
|
|
1365
|
-
│ ├── 缺陷洩漏 = 生產環境缺陷 / 總缺陷 │
|
|
1366
|
-
│ ├── 測試效能 = 找到的缺陷 / 存在的缺陷 │
|
|
1367
|
-
│ └── 階段封閉 = 階段中找到的缺陷 / 注入的缺陷 │
|
|
1368
|
-
│ │
|
|
1369
|
-
│ 進度度量 │
|
|
1370
|
-
│ ├── 測試執行率 = 執行的測試 / 計劃的測試 │
|
|
1371
|
-
│ ├── 通過率 = 通過的測試 / 執行的測試 │
|
|
1372
|
-
│ └── 阻塞率 = 被阻塞的測試 / 總測試 │
|
|
1373
|
-
│ │
|
|
1374
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1375
|
-
```
|
|
1376
|
-
|
|
1377
|
-
---
|
|
1378
|
-
|
|
1379
|
-
## 缺陷管理
|
|
1380
|
-
|
|
1381
|
-
系統化地追蹤和管理整個測試生命週期中的缺陷。
|
|
1382
|
-
|
|
1383
|
-
**參考來源**:ISTQB CTFL v4.0 第 5.5 節、ISO/IEC/IEEE 29119-3
|
|
1384
|
-
|
|
1385
|
-
### 缺陷生命週期
|
|
1386
|
-
|
|
1387
|
-
```
|
|
1388
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1389
|
-
│ 缺陷生命週期 │
|
|
1390
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1391
|
-
│ │
|
|
1392
|
-
│ ┌────────┐ ┌────────┐ ┌──────────┐ │
|
|
1393
|
-
│ │ 新建 │───▶│ 開啟 │───▶│ 處理中 │ │
|
|
1394
|
-
│ └────────┘ └────────┘ └──────────┘ │
|
|
1395
|
-
│ │ │ │
|
|
1396
|
-
│ │ ▼ │
|
|
1397
|
-
│ │ ┌──────────┐ │
|
|
1398
|
-
│ │ │ 已修復 │ │
|
|
1399
|
-
│ │ └──────────┘ │
|
|
1400
|
-
│ │ │ │
|
|
1401
|
-
│ │ ▼ │
|
|
1402
|
-
│ │ ┌──────────┐ ┌──────────┐ │
|
|
1403
|
-
│ │ │ 已驗證 │───▶│ 已關閉 │ │
|
|
1404
|
-
│ │ └──────────┘ └──────────┘ │
|
|
1405
|
-
│ │ │ │
|
|
1406
|
-
│ │ ▼ │
|
|
1407
|
-
│ │ ┌──────────┐ │
|
|
1408
|
-
│ └───────▶│ 重新開啟 │ │
|
|
1409
|
-
│ └──────────┘ │
|
|
1410
|
-
│ │
|
|
1411
|
-
│ 替代路徑: │
|
|
1412
|
-
│ - 新建 → 已拒絕(非 bug、重複) │
|
|
1413
|
-
│ - 開啟 → 延後(延後到以後的版本) │
|
|
1414
|
-
│ - 開啟 → 不修復(接受風險) │
|
|
1415
|
-
│ │
|
|
1416
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1417
|
-
```
|
|
1418
|
-
|
|
1419
|
-
### 嚴重性 vs 優先順序
|
|
1420
|
-
|
|
1421
|
-
| 嚴重性 | 描述 | 範例 |
|
|
1422
|
-
|--------|------|------|
|
|
1423
|
-
| 嚴重 | 系統崩潰、資料遺失、安全漏洞 | 應用無法啟動、資料損壞 |
|
|
1424
|
-
| 高 | 主要功能損壞、無替代方案 | 無法完成結帳 |
|
|
1425
|
-
| 中 | 功能受損但有替代方案 | 匯出失敗、手動複製可行 |
|
|
1426
|
-
| 低 | 小問題、外觀問題 | 錯字、對齊問題 |
|
|
1427
|
-
|
|
1428
|
-
| 優先順序 | 描述 | 回應時間 |
|
|
1429
|
-
|----------|------|----------|
|
|
1430
|
-
| P1 | 立即修復 | 當天 |
|
|
1431
|
-
| P2 | 發布前修復 | Sprint 內 |
|
|
1432
|
-
| P3 | 可能時修復 | 下個 Sprint |
|
|
1433
|
-
| P4 | 有空時修復 | 待辦清單 |
|
|
1434
|
-
|
|
1435
|
-
### 缺陷指標
|
|
1436
|
-
|
|
1437
|
-
```
|
|
1438
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1439
|
-
│ 關鍵缺陷指標 │
|
|
1440
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1441
|
-
│ │
|
|
1442
|
-
│ 缺陷密度 = 總缺陷數 / 規模(KLOC 或 FP) │
|
|
1443
|
-
│ - 行業平均:1-25 缺陷/KLOC │
|
|
1444
|
-
│ │
|
|
1445
|
-
│ 缺陷檢測效率(DDE)= │
|
|
1446
|
-
│ 發布前發現的缺陷 / 總缺陷 × 100 │
|
|
1447
|
-
│ - 目標:> 90% │
|
|
1448
|
-
│ │
|
|
1449
|
-
│ 缺陷移除效率(DRE)= │
|
|
1450
|
-
│ 移除的缺陷 / 注入的缺陷 × 100 │
|
|
1451
|
-
│ - 目標:> 95% │
|
|
1452
|
-
│ │
|
|
1453
|
-
│ 平均檢測時間(MTTD)= 從注入到檢測的平均時間 │
|
|
1454
|
-
│ 平均解決時間(MTTR)= 從報告到修復的平均時間 │
|
|
1455
|
-
│ │
|
|
1456
|
-
│ 缺陷洩漏率 = 生產缺陷 / 總缺陷 │
|
|
1457
|
-
│ - 目標:< 5% │
|
|
1458
|
-
│ │
|
|
1459
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
---
|
|
1463
|
-
|
|
1464
|
-
## 測試流程管理
|
|
1465
|
-
|
|
1466
|
-
規劃、監控和控制測試活動的結構化方法。
|
|
1467
|
-
|
|
1468
|
-
**參考來源**:ISTQB CTFL v4.0 第 5 章、ISO/IEC/IEEE 29119-2
|
|
1469
|
-
|
|
1470
|
-
### 測試計畫
|
|
1471
|
-
|
|
1472
|
-
#### 測試計畫組成(ISO/IEC/IEEE 29119-3)
|
|
1473
|
-
|
|
1474
|
-
```
|
|
1475
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1476
|
-
│ 測試計畫結構 │
|
|
1477
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1478
|
-
│ │
|
|
1479
|
-
│ 1. 測試計畫識別 │
|
|
1480
|
-
│ - 專案名稱、版本、日期 │
|
|
1481
|
-
│ │
|
|
1482
|
-
│ 2. 簡介 │
|
|
1483
|
-
│ - 目的、範圍、目標 │
|
|
1484
|
-
│ │
|
|
1485
|
-
│ 3. 測試項目 │
|
|
1486
|
-
│ - 要測試的功能 │
|
|
1487
|
-
│ - 不測試的功能 │
|
|
1488
|
-
│ │
|
|
1489
|
-
│ 4. 測試方法 │
|
|
1490
|
-
│ - 測試層級和類型 │
|
|
1491
|
-
│ - 測試技術 │
|
|
1492
|
-
│ - 進入/退出條件 │
|
|
1493
|
-
│ │
|
|
1494
|
-
│ 5. 測試環境 │
|
|
1495
|
-
│ - 硬體、軟體、工具 │
|
|
1496
|
-
│ - 測試資料需求 │
|
|
1497
|
-
│ │
|
|
1498
|
-
│ 6. 測試排程 │
|
|
1499
|
-
│ - 里程碑、相依性 │
|
|
1500
|
-
│ │
|
|
1501
|
-
│ 7. 角色與職責 │
|
|
1502
|
-
│ - 團隊結構、RACI 矩陣 │
|
|
1503
|
-
│ │
|
|
1504
|
-
│ 8. 風險與應變措施 │
|
|
1505
|
-
│ - 風險評估、緩解 │
|
|
1506
|
-
│ │
|
|
1507
|
-
│ 9. 核准 │
|
|
1508
|
-
│ - 簽核要求 │
|
|
1509
|
-
│ │
|
|
1510
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1511
|
-
```
|
|
1512
|
-
|
|
1513
|
-
#### 進入和退出條件
|
|
1514
|
-
|
|
1515
|
-
| 條件類型 | 範例 |
|
|
1516
|
-
|----------|------|
|
|
1517
|
-
| **進入條件**(開始測試)| 需求已核准、程式碼完成、環境就緒、測試資料可用 |
|
|
1518
|
-
| **退出條件**(停止測試)| 所有 P1/P2 測試通過、覆蓋率達標、無嚴重缺陷開啟 |
|
|
1519
|
-
|
|
1520
|
-
### 測試監控與控制
|
|
1521
|
-
|
|
1522
|
-
#### 關鍵進度指標
|
|
1523
|
-
|
|
1524
|
-
```
|
|
1525
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1526
|
-
│ 測試進度指標 │
|
|
1527
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1528
|
-
│ │
|
|
1529
|
-
│ 執行指標: │
|
|
1530
|
-
│ - 計畫測試數:500 │
|
|
1531
|
-
│ - 已執行測試:350(70%) │
|
|
1532
|
-
│ - 測試通過:320(已執行的 91%) │
|
|
1533
|
-
│ - 測試失敗:30(已執行的 9%) │
|
|
1534
|
-
│ - 測試阻塞:15 │
|
|
1535
|
-
│ │
|
|
1536
|
-
│ 缺陷指標: │
|
|
1537
|
-
│ - 發現的總缺陷:45 │
|
|
1538
|
-
│ - 開啟的缺陷:12(3 個嚴重、5 個高、4 個中) │
|
|
1539
|
-
│ - 已修復的缺陷:28 │
|
|
1540
|
-
│ - 已驗證的缺陷:20 │
|
|
1541
|
-
│ │
|
|
1542
|
-
│ 覆蓋率指標: │
|
|
1543
|
-
│ - 需求覆蓋率:85% │
|
|
1544
|
-
│ - 程式碼覆蓋率:78% │
|
|
1545
|
-
│ - 風險覆蓋率:90% │
|
|
1546
|
-
│ │
|
|
1547
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1548
|
-
```
|
|
1549
|
-
|
|
1550
|
-
---
|
|
1551
|
-
|
|
1552
|
-
## 測試替身
|
|
1553
|
-
|
|
1554
|
-
### 類型
|
|
1555
|
-
|
|
1556
|
-
| 類型 | 用途 | 使用範例 |
|
|
1557
|
-
|------|------|----------|
|
|
1558
|
-
| **Stub** (樁) | 回傳預定值 | 固定的 API 回應 |
|
|
1559
|
-
| **Mock** (模擬物件) | 驗證互動 | 驗證方法被呼叫 |
|
|
1560
|
-
| **Fake** (假物件) | 簡化的實作 | 記憶體資料庫 |
|
|
1561
|
-
| **Spy** (間諜) | 記錄呼叫,委派給真實物件 | 部分模擬 |
|
|
1562
|
-
| **Dummy** (虛設物件) | 佔位符,從不使用 | 填充必要參數 |
|
|
1563
|
-
|
|
1564
|
-
### 使用指引
|
|
1565
|
-
|
|
1566
|
-
```
|
|
1567
|
-
┌─────────────────────────────────────────────────────────┐
|
|
1568
|
-
│ 何時使用哪種替身 │
|
|
1569
|
-
├─────────────────────────────────────────────────────────┤
|
|
1570
|
-
│ 單元測試 (UT) │
|
|
1571
|
-
│ ├── 對所有外部相依使用 Mocks/Stubs │
|
|
1572
|
-
│ └── 使用 Mocks 驗證互動 │
|
|
1573
|
-
├─────────────────────────────────────────────────────────┤
|
|
1574
|
-
│ 整合測試 (IT) │
|
|
1575
|
-
│ ├── 對資料庫使用 Fakes(記憶體、容器) │
|
|
1576
|
-
│ ├── 對外部 API 使用 Stubs │
|
|
1577
|
-
│ └── 最小化 mocking - 測試真實整合 │
|
|
1578
|
-
├─────────────────────────────────────────────────────────┤
|
|
1579
|
-
│ 系統測試 (ST) │
|
|
1580
|
-
│ ├── 盡可能使用真實元件 │
|
|
1581
|
-
│ ├── 僅對外部第三方服務使用 Fakes │
|
|
1582
|
-
│ └── 系統邊界內不使用 mocking │
|
|
1583
|
-
├─────────────────────────────────────────────────────────┤
|
|
1584
|
-
│ E2E 測試 │
|
|
1585
|
-
│ ├── 使用真實的一切 │
|
|
1586
|
-
│ └── 僅對外部支付/郵件服務使用 Stub │
|
|
1587
|
-
└─────────────────────────────────────────────────────────┘
|
|
1588
|
-
```
|
|
174
|
+
| 層級 | 指引 |
|
|
175
|
+
|------|------|
|
|
176
|
+
| **UT** | 對所有外部依賴使用 Mocks/Stubs |
|
|
177
|
+
| **IT** | 資料庫使用 Fakes,外部 API 使用 Stubs |
|
|
178
|
+
| **E2E** | 全部使用真實元件;僅外部支付/郵件使用 Stub |
|
|
1589
179
|
|
|
1590
180
|
---
|
|
1591
181
|
|
|
1592
182
|
## Mock 限制
|
|
1593
183
|
|
|
1594
|
-
|
|
184
|
+
**問題**: 萬用匹配器 (`any()`, `It.IsAny<>`) 會忽略實際查詢邏輯,允許錯誤的查詢通過。
|
|
1595
185
|
|
|
1596
|
-
|
|
1597
|
-
當 Mock 接受查詢條件的 Repository 方法時(如 lambda 表達式、過濾函式),
|
|
1598
|
-
使用萬用匹配器如 `any()` 會忽略實際的查詢邏輯,讓錯誤的查詢通過單元測試。
|
|
1599
|
-
|
|
1600
|
-
**範例**:
|
|
186
|
+
**規則**: 如果 Mock 一個接受查詢/過濾/述詞參數的方法,你**必須**有對應的整合測試來驗證查詢邏輯。
|
|
1601
187
|
|
|
1602
188
|
```python
|
|
1603
|
-
# Python
|
|
1604
|
-
# ❌
|
|
189
|
+
# 範例 - Python
|
|
190
|
+
# ❌ 此測試無法驗證查詢正確性
|
|
1605
191
|
mock_repo.find.return_value = users
|
|
1606
|
-
# 查詢可能寫錯,測試仍會通過
|
|
1607
|
-
|
|
1608
|
-
# ✓ 新增整合測試驗證實際查詢
|
|
1609
|
-
```
|
|
1610
192
|
|
|
1611
|
-
|
|
1612
|
-
// C# 範例
|
|
1613
|
-
// ❌ Moq 忽略實際的表達式
|
|
1614
|
-
_repo.Setup(r => r.FindAsync(It.IsAny<Expression<Func<User, bool>>>()))
|
|
1615
|
-
.ReturnsAsync(users);
|
|
1616
|
-
|
|
1617
|
-
// ✓ 用整合測試驗證,或使用 It.Is<> 來驗證
|
|
193
|
+
# ✓ 新增整合測試來驗證實際查詢
|
|
1618
194
|
```
|
|
1619
195
|
|
|
1620
|
-
**經驗法則**:
|
|
1621
|
-
如果你的單元測試 Mock 了一個接受查詢/過濾/條件參數的方法,
|
|
1622
|
-
你必須有對應的整合測試來驗證查詢邏輯。
|
|
1623
|
-
|
|
1624
196
|
---
|
|
1625
197
|
|
|
1626
|
-
##
|
|
1627
|
-
|
|
1628
|
-
### 原則
|
|
1629
|
-
|
|
1630
|
-
1. **隔離**: 每個測試管理自己的資料
|
|
1631
|
-
2. **清理**: 測試結束後自行清理
|
|
1632
|
-
3. **確定性**: 測試不依賴共享狀態
|
|
1633
|
-
4. **可讀性**: 測試資料清楚顯示意圖
|
|
1634
|
-
|
|
1635
|
-
### 模式
|
|
1636
|
-
|
|
1637
|
-
```csharp
|
|
1638
|
-
// Builder 模式建立測試資料
|
|
1639
|
-
public class UserBuilder
|
|
1640
|
-
{
|
|
1641
|
-
private string _name = "Default User";
|
|
1642
|
-
private string _email = "default@example.com";
|
|
1643
|
-
private bool _isActive = true;
|
|
1644
|
-
|
|
1645
|
-
public UserBuilder WithName(string name)
|
|
1646
|
-
{
|
|
1647
|
-
_name = name;
|
|
1648
|
-
return this;
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
public UserBuilder WithEmail(string email)
|
|
1652
|
-
{
|
|
1653
|
-
_email = email;
|
|
1654
|
-
return this;
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
public UserBuilder Inactive()
|
|
1658
|
-
{
|
|
1659
|
-
_isActive = false;
|
|
1660
|
-
return this;
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
public User Build() => new User
|
|
1664
|
-
{
|
|
1665
|
-
Name = _name,
|
|
1666
|
-
Email = _email,
|
|
1667
|
-
IsActive = _isActive
|
|
1668
|
-
};
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
// 在測試中使用
|
|
1672
|
-
var activeUser = new UserBuilder()
|
|
1673
|
-
.WithName("Active User")
|
|
1674
|
-
.Build();
|
|
1675
|
-
|
|
1676
|
-
var inactiveUser = new UserBuilder()
|
|
1677
|
-
.WithName("Inactive User")
|
|
1678
|
-
.Inactive()
|
|
1679
|
-
.Build();
|
|
1680
|
-
```
|
|
1681
|
-
|
|
1682
|
-
### 區分識別欄位
|
|
198
|
+
## 測試資料需求
|
|
1683
199
|
|
|
1684
|
-
|
|
1685
|
-
測試資料必須使用不同的值。
|
|
200
|
+
### 區分識別碼規則
|
|
1686
201
|
|
|
1687
|
-
|
|
1688
|
-
如果測試資料在兩個欄位使用相同的值,欄位映射錯誤將無法被發現。
|
|
202
|
+
當實體同時具有代理鍵 (自動產生 ID) 和業務識別碼時,測試資料**必須**為兩者使用不同的值。
|
|
1689
203
|
|
|
1690
204
|
```python
|
|
1691
|
-
#
|
|
1692
|
-
# ❌ 錯誤:id 與 business_code 相同
|
|
205
|
+
# ❌ 錯誤: id 等於 business_code - 對應錯誤無法偵測
|
|
1693
206
|
dept = Department(id=1, business_code=1)
|
|
1694
207
|
|
|
1695
|
-
# ✓
|
|
208
|
+
# ✓ 正確: 區分值可捕捉對應錯誤
|
|
1696
209
|
dept = Department(id=1, business_code=1001)
|
|
1697
210
|
```
|
|
1698
211
|
|
|
1699
|
-
```csharp
|
|
1700
|
-
// C# 範例
|
|
1701
|
-
// ❌ 錯誤:Id 與 DeptId 相同 - 映射錯誤不會被發現
|
|
1702
|
-
var dept = new Department { Id = 1, DeptId = 1 };
|
|
1703
|
-
|
|
1704
|
-
// ✓ 正確:不同的值能抓到欄位映射錯誤
|
|
1705
|
-
var dept = new Department { Id = 1, DeptId = 1001 };
|
|
1706
|
-
```
|
|
1707
|
-
|
|
1708
|
-
**驗證**:
|
|
1709
|
-
```csharp
|
|
1710
|
-
// C#
|
|
1711
|
-
testData.Dept.Id.Should().NotBe(testData.Dept.DeptId,
|
|
1712
|
-
"Test precondition: Id must differ from business identifier");
|
|
1713
|
-
```
|
|
1714
|
-
|
|
1715
|
-
### 複合主鍵
|
|
1716
|
-
|
|
1717
|
-
對於使用複合主鍵的實體,確保每筆記錄有唯一的主鍵組合。
|
|
1718
|
-
|
|
1719
|
-
```csharp
|
|
1720
|
-
// C# 範例
|
|
1721
|
-
// ❌ 主鍵衝突 - 相同的 (Id, SendTime) 組合
|
|
1722
|
-
var batch1 = new BatchRecord { Id = 0, SendTime = now };
|
|
1723
|
-
var batch2 = new BatchRecord { Id = 0, SendTime = now }; // 衝突!
|
|
1724
|
-
|
|
1725
|
-
// ✓ 唯一組合
|
|
1726
|
-
var batch1 = new BatchRecord { Id = 0, SendTime = now.AddSeconds(1) };
|
|
1727
|
-
var batch2 = new BatchRecord { Id = 0, SendTime = now.AddSeconds(2) };
|
|
1728
|
-
```
|
|
1729
|
-
|
|
1730
|
-
**提示**:建立自動產生唯一複合主鍵的輔助函式。
|
|
1731
|
-
|
|
1732
|
-
```csharp
|
|
1733
|
-
// C# 輔助函式範例
|
|
1734
|
-
private static int _timeOffset = 0;
|
|
1735
|
-
public static BatchRecord CreateWithUniqueKey(DateTime baseTime)
|
|
1736
|
-
{
|
|
1737
|
-
return new BatchRecord
|
|
1738
|
-
{
|
|
1739
|
-
SendTime = baseTime.AddSeconds(Interlocked.Increment(ref _timeOffset))
|
|
1740
|
-
};
|
|
1741
|
-
}
|
|
1742
|
-
```
|
|
1743
|
-
|
|
1744
212
|
---
|
|
1745
213
|
|
|
1746
|
-
##
|
|
1747
|
-
|
|
1748
|
-
### 目的
|
|
1749
|
-
|
|
1750
|
-
確保在開發機器與 CI/CD 管線之間獲得一致、可重現的測試結果。
|
|
1751
|
-
|
|
1752
|
-
### 為什麼重要
|
|
1753
|
-
|
|
1754
|
-
- **可重現性**: 相同測試在任何地方產生相同結果
|
|
1755
|
-
- **隔離性**: 專案相依性不與系統或其他專案衝突
|
|
1756
|
-
- **CI/CD 一致性**: 本地環境與 CI 環境相符
|
|
1757
|
-
|
|
1758
|
-
### 語言專屬虛擬環境
|
|
1759
|
-
|
|
1760
|
-
| 語言 | 工具 | Lock 檔案 |
|
|
1761
|
-
|------|------|-----------|
|
|
1762
|
-
| Python | venv, virtualenv, conda, poetry | requirements.txt, poetry.lock |
|
|
1763
|
-
| Node.js | nvm, fnm + npm/yarn/pnpm | package-lock.json, yarn.lock |
|
|
1764
|
-
| Ruby | rbenv, rvm, bundler | Gemfile.lock |
|
|
1765
|
-
| Java | SDKMAN, jenv, Maven/Gradle | pom.xml, build.gradle.lock |
|
|
1766
|
-
| .NET | dotnet SDK | packages.lock.json |
|
|
1767
|
-
| Go | go mod | go.sum |
|
|
1768
|
-
| Rust | rustup, cargo | Cargo.lock |
|
|
1769
|
-
|
|
1770
|
-
#### 最佳實踐
|
|
1771
|
-
|
|
1772
|
-
1. **開發和測試時始終使用虛擬環境**
|
|
1773
|
-
2. **將 lock 檔提交到版本控制**
|
|
1774
|
-
3. **在 CI/CD 管線中鎖定版本**
|
|
1775
|
-
4. **在 README 或 .tool-versions 記錄所需的執行環境版本**
|
|
1776
|
-
|
|
1777
|
-
#### 範例:Python 使用 venv
|
|
1778
|
-
|
|
1779
|
-
```bash
|
|
1780
|
-
# 建立虛擬環境
|
|
1781
|
-
python -m venv .venv
|
|
1782
|
-
|
|
1783
|
-
# 啟用
|
|
1784
|
-
source .venv/bin/activate # Linux/macOS
|
|
1785
|
-
.venv\Scripts\activate # Windows
|
|
1786
|
-
|
|
1787
|
-
# 安裝相依套件
|
|
1788
|
-
pip install -r requirements.txt
|
|
1789
|
-
|
|
1790
|
-
# 執行測試
|
|
1791
|
-
pytest tests/
|
|
1792
|
-
```
|
|
1793
|
-
|
|
1794
|
-
#### 範例:Node.js 使用 nvm
|
|
1795
|
-
|
|
1796
|
-
```bash
|
|
1797
|
-
# 使用專案的 Node 版本
|
|
1798
|
-
nvm use
|
|
1799
|
-
|
|
1800
|
-
# 安裝相依套件
|
|
1801
|
-
npm ci
|
|
1802
|
-
|
|
1803
|
-
# 執行測試
|
|
1804
|
-
npm test
|
|
1805
|
-
```
|
|
1806
|
-
|
|
1807
|
-
### 容器化測試
|
|
214
|
+
## 測試環境
|
|
1808
215
|
|
|
1809
|
-
|
|
216
|
+
### 依測試層級的容器使用
|
|
1810
217
|
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
|
1814
|
-
|
|
1815
|
-
|
|
|
1816
|
-
|
|
|
1817
|
-
| ST (系統測試) | ✅ Docker Compose 用於完整環境 |
|
|
1818
|
-
| E2E (端對端) | ✅ 完整容器化堆疊 |
|
|
1819
|
-
|
|
1820
|
-
#### Testcontainers
|
|
1821
|
-
|
|
1822
|
-
Testcontainers 提供輕量級、可拋棄式的測試容器。
|
|
1823
|
-
|
|
1824
|
-
```csharp
|
|
1825
|
-
// C# 範例使用 Testcontainers
|
|
1826
|
-
public class DatabaseIntegrationTests : IAsyncLifetime
|
|
1827
|
-
{
|
|
1828
|
-
private readonly PostgreSqlContainer _postgres = new PostgreSqlBuilder()
|
|
1829
|
-
.WithImage("postgres:15")
|
|
1830
|
-
.Build();
|
|
1831
|
-
|
|
1832
|
-
public async Task InitializeAsync()
|
|
1833
|
-
{
|
|
1834
|
-
await _postgres.StartAsync();
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
public async Task DisposeAsync()
|
|
1838
|
-
{
|
|
1839
|
-
await _postgres.DisposeAsync();
|
|
1840
|
-
}
|
|
1841
|
-
|
|
1842
|
-
[Fact]
|
|
1843
|
-
public async Task Should_Connect_To_Database()
|
|
1844
|
-
{
|
|
1845
|
-
var connectionString = _postgres.GetConnectionString();
|
|
1846
|
-
// 使用 connectionString 進行測試
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
```
|
|
1850
|
-
|
|
1851
|
-
```python
|
|
1852
|
-
# Python 範例使用 Testcontainers
|
|
1853
|
-
import pytest
|
|
1854
|
-
from testcontainers.postgres import PostgresContainer
|
|
1855
|
-
|
|
1856
|
-
@pytest.fixture(scope="module")
|
|
1857
|
-
def postgres_container():
|
|
1858
|
-
with PostgresContainer("postgres:15") as postgres:
|
|
1859
|
-
yield postgres
|
|
1860
|
-
|
|
1861
|
-
def test_database_connection(postgres_container):
|
|
1862
|
-
connection_url = postgres_container.get_connection_url()
|
|
1863
|
-
# 使用 connection_url 進行測試
|
|
1864
|
-
```
|
|
1865
|
-
|
|
1866
|
-
#### Docker Compose 用於系統測試
|
|
1867
|
-
|
|
1868
|
-
```yaml
|
|
1869
|
-
# docker-compose.test.yml
|
|
1870
|
-
version: '3.8'
|
|
1871
|
-
services:
|
|
1872
|
-
app:
|
|
1873
|
-
build: .
|
|
1874
|
-
depends_on:
|
|
1875
|
-
- db
|
|
1876
|
-
- redis
|
|
1877
|
-
- rabbitmq
|
|
1878
|
-
environment:
|
|
1879
|
-
- DATABASE_URL=postgres://test:test@db:5432/testdb
|
|
1880
|
-
- REDIS_URL=redis://redis:6379
|
|
1881
|
-
- RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672
|
|
1882
|
-
|
|
1883
|
-
db:
|
|
1884
|
-
image: postgres:15
|
|
1885
|
-
environment:
|
|
1886
|
-
POSTGRES_USER: test
|
|
1887
|
-
POSTGRES_PASSWORD: test
|
|
1888
|
-
POSTGRES_DB: testdb
|
|
1889
|
-
|
|
1890
|
-
redis:
|
|
1891
|
-
image: redis:7-alpine
|
|
1892
|
-
|
|
1893
|
-
rabbitmq:
|
|
1894
|
-
image: rabbitmq:3-management
|
|
1895
|
-
```
|
|
1896
|
-
|
|
1897
|
-
```bash
|
|
1898
|
-
# 使用 Docker Compose 執行系統測試
|
|
1899
|
-
docker-compose -f docker-compose.test.yml up -d
|
|
1900
|
-
npm run test:system
|
|
1901
|
-
docker-compose -f docker-compose.test.yml down -v
|
|
1902
|
-
```
|
|
1903
|
-
|
|
1904
|
-
### 環境一致性檢查清單
|
|
1905
|
-
|
|
1906
|
-
```
|
|
1907
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
1908
|
-
│ 環境一致性檢查清單 │
|
|
1909
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1910
|
-
│ ✅ 本地與 CI 使用相同的執行環境版本(Node, Python 等) │
|
|
1911
|
-
│ ✅ 容器與生產使用相同的資料庫版本 │
|
|
1912
|
-
│ ✅ Lock 檔案已提交並在 CI 中使用(npm ci, pip -r) │
|
|
1913
|
-
│ ✅ 環境變數有文件並保持一致 │
|
|
1914
|
-
│ ✅ 容器映像使用特定版本標籤 │
|
|
1915
|
-
│ ✅ 使用 .tool-versions 或類似工具管理執行環境版本 │
|
|
1916
|
-
├─────────────────────────────────────────────────────────────┤
|
|
1917
|
-
│ ❌ 在生產/CI 中使用 "latest" 標籤 │
|
|
1918
|
-
│ ❌ 開發與 CI 使用不同的資料庫版本 │
|
|
1919
|
-
│ ❌ 儲存庫中缺少 lock 檔案 │
|
|
1920
|
-
│ ❌ 硬編碼路徑或機器特定設定 │
|
|
1921
|
-
└─────────────────────────────────────────────────────────────┘
|
|
1922
|
-
```
|
|
218
|
+
| 層級 | 容器使用 |
|
|
219
|
+
|------|----------|
|
|
220
|
+
| UT | 不需要 - 使用 mocks |
|
|
221
|
+
| IT | Testcontainers 用於資料庫、快取 |
|
|
222
|
+
| ST | Docker Compose 用於完整環境 |
|
|
223
|
+
| E2E | 完整容器化堆疊 |
|
|
1923
224
|
|
|
1924
225
|
---
|
|
1925
226
|
|
|
@@ -1927,301 +228,23 @@ docker-compose -f docker-compose.test.yml down -v
|
|
|
1927
228
|
|
|
1928
229
|
### 測試執行策略
|
|
1929
230
|
|
|
1930
|
-
|
|
1931
|
-
# CI 管線範例
|
|
1932
|
-
stages:
|
|
1933
|
-
- unit-test # 每次提交執行
|
|
1934
|
-
- integration-test # 每次提交執行
|
|
1935
|
-
- system-test # PR 合併到 main 時執行
|
|
1936
|
-
- e2e-test # 發布候選版本時執行
|
|
1937
|
-
|
|
1938
|
-
unit-test:
|
|
1939
|
-
stage: unit-test
|
|
1940
|
-
script:
|
|
1941
|
-
- npm run test:unit
|
|
1942
|
-
timeout: 10m
|
|
1943
|
-
rules:
|
|
1944
|
-
- if: $CI_PIPELINE_SOURCE == "push"
|
|
1945
|
-
|
|
1946
|
-
integration-test:
|
|
1947
|
-
stage: integration-test
|
|
1948
|
-
services:
|
|
1949
|
-
- postgres:14
|
|
1950
|
-
- redis:7
|
|
1951
|
-
script:
|
|
1952
|
-
- npm run test:integration
|
|
1953
|
-
timeout: 30m
|
|
1954
|
-
rules:
|
|
1955
|
-
- if: $CI_PIPELINE_SOURCE == "push"
|
|
1956
|
-
|
|
1957
|
-
system-test:
|
|
1958
|
-
stage: system-test
|
|
1959
|
-
environment: staging
|
|
1960
|
-
script:
|
|
1961
|
-
- npm run test:system
|
|
1962
|
-
timeout: 2h
|
|
1963
|
-
rules:
|
|
1964
|
-
- if: $CI_COMMIT_BRANCH == "main"
|
|
1965
|
-
|
|
1966
|
-
e2e-test:
|
|
1967
|
-
stage: e2e-test
|
|
1968
|
-
environment: staging
|
|
1969
|
-
script:
|
|
1970
|
-
- npm run test:e2e
|
|
1971
|
-
timeout: 4h
|
|
1972
|
-
rules:
|
|
1973
|
-
- if: $CI_COMMIT_TAG
|
|
1974
|
-
```
|
|
1975
|
-
|
|
1976
|
-
### 測試報告
|
|
1977
|
-
|
|
1978
|
-
每個測試層級所需的指標:
|
|
1979
|
-
|
|
1980
|
-
| 指標 | UT | IT | ST | E2E |
|
|
1981
|
-
|------|----|----|----|----|
|
|
1982
|
-
| 通過/失敗計數 | ✅ | ✅ | ✅ | ✅ |
|
|
1983
|
-
| 執行時間 | ✅ | ✅ | ✅ | ✅ |
|
|
1984
|
-
| 覆蓋率 % | ✅ | ✅ | ⚠️ | ❌ |
|
|
1985
|
-
| 不穩定測試率 | ✅ | ✅ | ✅ | ✅ |
|
|
1986
|
-
| 截圖/影片 | ❌ | ❌ | ⚠️ | ✅ |
|
|
1987
|
-
|
|
1988
|
-
---
|
|
1989
|
-
|
|
1990
|
-
## 最佳實踐
|
|
1991
|
-
|
|
1992
|
-
### AAA 模式
|
|
1993
|
-
|
|
1994
|
-
```csharp
|
|
1995
|
-
[TestMethod]
|
|
1996
|
-
public void MethodName_Scenario_ExpectedBehavior()
|
|
1997
|
-
{
|
|
1998
|
-
// Arrange - 準備測試資料與環境
|
|
1999
|
-
var input = CreateTestInput();
|
|
2000
|
-
var sut = new SystemUnderTest();
|
|
2001
|
-
|
|
2002
|
-
// Act - 執行被測試的行為
|
|
2003
|
-
var result = sut.Execute(input);
|
|
2004
|
-
|
|
2005
|
-
// Assert - 驗證結果
|
|
2006
|
-
Assert.AreEqual(expected, result);
|
|
2007
|
-
}
|
|
2008
|
-
```
|
|
2009
|
-
|
|
2010
|
-
### FIRST 原則
|
|
2011
|
-
|
|
2012
|
-
| 原則 | 說明 |
|
|
2013
|
-
|------|------|
|
|
2014
|
-
| **F**ast (快速) | 測試執行迅速 |
|
|
2015
|
-
| **I**ndependent (獨立) | 測試不互相影響 |
|
|
2016
|
-
| **R**epeatable (可重複) | 每次結果相同 |
|
|
2017
|
-
| **S**elf-validating (自我驗證) | 明確的通過/失敗 |
|
|
2018
|
-
| **T**imely (及時) | 與生產程式碼一起撰寫 |
|
|
2019
|
-
|
|
2020
|
-
### 應避免的反模式
|
|
2021
|
-
|
|
2022
|
-
```
|
|
2023
|
-
❌ 測試相依
|
|
2024
|
-
測試必須按特定順序執行
|
|
2025
|
-
|
|
2026
|
-
❌ 不穩定測試
|
|
2027
|
-
測試有時通過有時失敗
|
|
2028
|
-
|
|
2029
|
-
❌ 測試實作細節
|
|
2030
|
-
重構時測試會壞掉
|
|
2031
|
-
|
|
2032
|
-
❌ 過度模擬
|
|
2033
|
-
Mock 太多導致沒測到真正的東西
|
|
2034
|
-
|
|
2035
|
-
❌ 缺少斷言
|
|
2036
|
-
測試沒有驗證任何有意義的東西
|
|
2037
|
-
|
|
2038
|
-
❌ 魔術數字/字串
|
|
2039
|
-
測試程式碼中有未解釋的值
|
|
2040
|
-
|
|
2041
|
-
❌ 相同測試識別碼
|
|
2042
|
-
代理鍵和業務鍵使用相同的值
|
|
2043
|
-
```
|
|
2044
|
-
|
|
2045
|
-
---
|
|
2046
|
-
|
|
2047
|
-
## 測試文件結構
|
|
2048
|
-
|
|
2049
|
-
透過在測試目錄中維護標準化的文件結構,提升測試可發現性。
|
|
2050
|
-
|
|
2051
|
-
### tests/README.md 必要區塊
|
|
2052
|
-
|
|
2053
|
-
每個 `tests/` 目錄應包含 README.md,並具備以下區塊以提高可發現性。
|
|
2054
|
-
|
|
2055
|
-
#### 1. 測試總覽表格
|
|
2056
|
-
|
|
2057
|
-
列出所有測試類型、數量、技術棧和執行環境。
|
|
2058
|
-
|
|
2059
|
-
```markdown
|
|
2060
|
-
| 測試類型 | 數量 | 框架 | 環境 |
|
|
2061
|
-
|----------|------|------|------|
|
|
2062
|
-
| 單元測試 | 150 | Jest | Node.js |
|
|
2063
|
-
| 整合測試 | 45 | Jest | Node.js + TestContainers |
|
|
2064
|
-
| E2E 測試 | 12 | Playwright | 瀏覽器 |
|
|
2065
|
-
```
|
|
2066
|
-
|
|
2067
|
-
#### 2. 當前狀態區塊
|
|
2068
|
-
|
|
2069
|
-
顯示最新測試執行結果,包含清楚的通過/失敗指標。
|
|
2070
|
-
|
|
2071
|
-
```markdown
|
|
2072
|
-
## 當前狀態
|
|
2073
|
-
|
|
2074
|
-
| 指標 | 數值 | 目標 | 狀態 |
|
|
2075
|
-
|------|------|------|------|
|
|
2076
|
-
| 通過率 | 98.5% | ≥ 95% | ✅ |
|
|
2077
|
-
| 行覆蓋率 | 82% | ≥ 80% | ✅ |
|
|
2078
|
-
| 分支覆蓋率 | 75% | ≥ 70% | ✅ |
|
|
2079
|
-
|
|
2080
|
-
**最後執行**: 2026-01-20 14:30 UTC
|
|
2081
|
-
**報告**: [test-report-20260120-143000.md](results/test-report-20260120-143000.md)
|
|
2082
|
-
```
|
|
2083
|
-
|
|
2084
|
-
#### 3. 報告連結區塊
|
|
2085
|
-
|
|
2086
|
-
包含測試報告、差距分析和覆蓋率摘要的連結。
|
|
2087
|
-
|
|
2088
|
-
```markdown
|
|
2089
|
-
## 報告
|
|
2090
|
-
|
|
2091
|
-
| 報告類型 | 位置 | 說明 |
|
|
2092
|
-
|----------|------|------|
|
|
2093
|
-
| 測試結果 | `results/` | 帶時間戳的測試執行報告 |
|
|
2094
|
-
| 覆蓋率 | `coverage/` | 程式碼覆蓋率報告(HTML、JSON) |
|
|
2095
|
-
| 差距分析 | `docs/gap-analysis.md` | 缺失的測試覆蓋率分析 |
|
|
2096
|
-
```
|
|
2097
|
-
|
|
2098
|
-
### 測試報告命名規範
|
|
2099
|
-
|
|
2100
|
-
| 項目 | 規範 | 範例 |
|
|
231
|
+
| 階段 | 時機 | 逾時 |
|
|
2101
232
|
|------|------|------|
|
|
2102
|
-
|
|
|
2103
|
-
|
|
|
2104
|
-
|
|
|
2105
|
-
|
|
|
2106
|
-
|
|
2107
|
-
### 目錄結構範例
|
|
2108
|
-
|
|
2109
|
-
```
|
|
2110
|
-
tests/
|
|
2111
|
-
├── README.md # 測試總覽與狀態
|
|
2112
|
-
├── results/ # 測試執行報告
|
|
2113
|
-
│ ├── test-report-20260120-143000.md
|
|
2114
|
-
│ └── test-report-20260119-090000.md
|
|
2115
|
-
├── coverage/ # 覆蓋率報告
|
|
2116
|
-
│ ├── lcov-report/
|
|
2117
|
-
│ └── coverage-summary.json
|
|
2118
|
-
├── docs/ # 測試文件
|
|
2119
|
-
│ └── gap-analysis.md
|
|
2120
|
-
├── unit/ # 單元測試
|
|
2121
|
-
├── integration/ # 整合測試
|
|
2122
|
-
└── e2e/ # 端對端測試
|
|
2123
|
-
```
|
|
2124
|
-
|
|
2125
|
-
### 效益
|
|
2126
|
-
|
|
2127
|
-
| 效益 | 說明 |
|
|
2128
|
-
|------|------|
|
|
2129
|
-
| **可發現性** | 開發者可快速找到測試狀態,無需全面搜尋 |
|
|
2130
|
-
| **透明度** | 當前品質指標一目了然 |
|
|
2131
|
-
| **可追溯性** | 歷史報告支援趨勢分析 |
|
|
2132
|
-
| **新人入門** | 新團隊成員可立即理解測試結構 |
|
|
2133
|
-
|
|
2134
|
-
---
|
|
2135
|
-
|
|
2136
|
-
## 快速參考卡
|
|
2137
|
-
|
|
2138
|
-
```
|
|
2139
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
2140
|
-
│ 參考標準 │
|
|
2141
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2142
|
-
│ • ISTQB CTFL v4.0 - 測試認證 │
|
|
2143
|
-
│ • ISO/IEC/IEEE 29119 - 測試標準 │
|
|
2144
|
-
│ • SWEBOK v4.0 - 軟體工程知識體系 │
|
|
2145
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2146
|
-
│ 測試基礎(SWEBOK) │
|
|
2147
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2148
|
-
│ Error → Fault → Failure(因果鏈) │
|
|
2149
|
-
│ Oracle Problem:如何知道預期結果? │
|
|
2150
|
-
│ 限制:測試證明缺陷存在,無法證明不存在 │
|
|
2151
|
-
│ 可測試性:可控制性 + 可觀察性 + 可隔離性 │
|
|
2152
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2153
|
-
│ 測試框架選項 │
|
|
2154
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2155
|
-
│ ISTQB: UT → IT/SIT → ST → AT/UAT(企業/合規) │
|
|
2156
|
-
│ 業界金字塔: UT (70%) → IT (20%) → E2E (10%)(敏捷/DevOps)│
|
|
2157
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2158
|
-
│ 測試層級摘要 │
|
|
2159
|
-
├──────────┬──────────────────────────────────────────────────┤
|
|
2160
|
-
│ UT │ 單一單元、隔離、模擬相依、< 100ms │
|
|
2161
|
-
├──────────┼──────────────────────────────────────────────────┤
|
|
2162
|
-
│ IT/SIT │ 元件整合、真實資料庫、1-10 秒 │
|
|
2163
|
-
├──────────┼──────────────────────────────────────────────────┤
|
|
2164
|
-
│ ST │ 完整系統、基於需求(僅 ISTQB) │
|
|
2165
|
-
├──────────┼──────────────────────────────────────────────────┤
|
|
2166
|
-
│ E2E │ 使用者流程、UI 到 DB、僅關鍵路徑 │
|
|
2167
|
-
├──────────┼──────────────────────────────────────────────────┤
|
|
2168
|
-
│ AT/UAT │ 業務驗證、終端使用者(僅 ISTQB) │
|
|
2169
|
-
├──────────┴──────────────────────────────────────────────────┤
|
|
2170
|
-
│ 測試類型(ISTQB) │
|
|
2171
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2172
|
-
│ 功能性:驗證系統行為(黑箱) │
|
|
2173
|
-
│ 非功能性:效能、安全性、可用性 │
|
|
2174
|
-
│ 結構性:程式碼覆蓋、白箱技術 │
|
|
2175
|
-
│ 變更相關:確認測試與回歸測試 │
|
|
2176
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2177
|
-
│ 測試設計技術 │
|
|
2178
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2179
|
-
│ 黑箱:EP、BVA、決策表、狀態轉換 │
|
|
2180
|
-
│ 成對測試、用例測試 │
|
|
2181
|
-
│ 白箱:語句、分支、條件、MC/DC │
|
|
2182
|
-
│ 資料流(All-Defs、All-Uses) │
|
|
2183
|
-
│ 經驗:探索性、錯誤猜測、檢查表 │
|
|
2184
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2185
|
-
│ 覆蓋率目標 │
|
|
2186
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2187
|
-
│ 行: 最低 70% / 建議 85% │
|
|
2188
|
-
│ 分支: 最低 60% / 建議 80% │
|
|
2189
|
-
│ 函式: 最低 80% / 建議 90% │
|
|
2190
|
-
│ 變異分數:關鍵程式碼 ≥ 80% │
|
|
2191
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2192
|
-
│ 專項測試類型 │
|
|
2193
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2194
|
-
│ 契約:微服務 API 相容性 │
|
|
2195
|
-
│ 變異:透過程式碼變異評估測試品質 │
|
|
2196
|
-
│ 混沌:透過故障注入驗證韌性 │
|
|
2197
|
-
│ 屬性導向:基於屬性的隨機輸入 │
|
|
2198
|
-
│ 視覺回歸:UI 截圖比較 │
|
|
2199
|
-
│ 無障礙:WCAG 合規驗證 │
|
|
2200
|
-
│ 安裝:部署驗證 │
|
|
2201
|
-
│ 復原:失效復原(RTO/RPO) │
|
|
2202
|
-
│ 配置:多配置測試 │
|
|
2203
|
-
│ 易用性:使用者體驗(SUS、NPS) │
|
|
2204
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2205
|
-
│ 測試相關度量 │
|
|
2206
|
-
├─────────────────────────────────────────────────────────────┤
|
|
2207
|
-
│ 缺陷密度 = 缺陷數 / KLOC(目標:< 1) │
|
|
2208
|
-
│ 缺陷洩漏 = 生產環境缺陷 / 總缺陷(< 5%) │
|
|
2209
|
-
│ 缺陷植入:插入已知缺陷衡量偵測率 │
|
|
2210
|
-
│ 可靠度成長:追蹤缺陷率隨時間變化 │
|
|
2211
|
-
└─────────────────────────────────────────────────────────────┘
|
|
2212
|
-
```
|
|
233
|
+
| 單元測試 | 每次提交 | 10 分鐘 |
|
|
234
|
+
| 整合測試 | 每次提交 | 30 分鐘 |
|
|
235
|
+
| 系統測試 | PR 合併至 main | 2 小時 |
|
|
236
|
+
| E2E 測試 | 發布候選版 | 4 小時 |
|
|
2213
237
|
|
|
2214
238
|
---
|
|
2215
239
|
|
|
2216
240
|
## 相關標準
|
|
2217
241
|
|
|
242
|
+
- [測試理論知識庫](guides/testing-guide.md) - 教育內容、範例、技巧
|
|
2218
243
|
- [測試驅動開發](test-driven-development.md) - TDD/BDD/ATDD 方法論
|
|
2219
|
-
- [測試完整性維度](test-completeness-dimensions.md) -
|
|
244
|
+
- [測試完整性維度](test-completeness-dimensions.md) - 8 維度測試覆蓋
|
|
2220
245
|
- [規格驅動開發](spec-driven-development.md) - SDD 工作流程整合
|
|
2221
|
-
- [
|
|
2222
|
-
- [程式碼簽入檢查點標準](checkin-standards.md)
|
|
246
|
+
- [程式碼簽入標準](checkin-standards.md)
|
|
2223
247
|
- [程式碼審查清單](code-review-checklist.md)
|
|
2224
|
-
- [Commit 訊息規範](commit-message-guide.md)
|
|
2225
248
|
|
|
2226
249
|
---
|
|
2227
250
|
|
|
@@ -2229,21 +252,13 @@ tests/
|
|
|
2229
252
|
|
|
2230
253
|
| 版本 | 日期 | 變更 |
|
|
2231
254
|
|------|------|------|
|
|
2232
|
-
|
|
|
2233
|
-
| 2.
|
|
2234
|
-
| 2.
|
|
2235
|
-
|
|
|
2236
|
-
| 1.2.0 | 2025-12-19 | 新增:Mock 限制章節、整合測試必要性、區分識別欄位、複合主鍵測試資料模式 |
|
|
2237
|
-
| 1.1.1 | 2025-12-11 | 改進:系統測試範例改用通用領域概念取代特定業務術語 |
|
|
2238
|
-
| 1.1.0 | 2025-12-05 | 新增測試環境隔離章節(venv、容器) |
|
|
2239
|
-
| 1.0.0 | 2025-12-05 | 初始測試標準,涵蓋 UT/IT/ST/E2E |
|
|
255
|
+
| 3.0.0 | 2026-01-29 | **重大重構**:拆分為規則(本文件)和理論(testing-guide.md)。優化 AI 閱讀效率。 |
|
|
256
|
+
| 2.2.0 | 2026-01-20 | 新增測試文件結構章節 |
|
|
257
|
+
| 2.1.0 | 2026-01-05 | 新增 SWEBOK v4.0 參考 |
|
|
258
|
+
| 2.0.0 | 2026-01-05 | 根據 ISTQB CTFL v4.0 和 ISO/IEC/IEEE 29119 進行重大更新 |
|
|
2240
259
|
|
|
2241
260
|
---
|
|
2242
261
|
|
|
2243
262
|
## 授權
|
|
2244
263
|
|
|
2245
264
|
本標準以 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權發布。
|
|
2246
|
-
|
|
2247
|
-
---
|
|
2248
|
-
|
|
2249
|
-
**維護者**: 開發團隊
|