dotnet-testing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

.NET 測試基礎技能總覽

.NET Testing Basic Skills Overview



🤖 AI Agent 重要提示

🤖 AI Agent Important Note

當您(AI Agent)被載入此入口 skill 時,請先閱讀以下指引
When you (AI Agent) are loaded into this entry skill, please read the following guidelines first:

📋 本技能的定位

📋 Positioning of This Skill

本檔案是「導航中心」,用於幫助找到正確的子技能
This document is a "Navigation Hub" designed to help find the correct sub-skills.

您的任務是

Your Tasks Are

  1. ✅ 根據使用者需求匹配對應的子技能
  2. ✅ 使用
    Skill
    tool 載入具體的子技能
  3. ✅ 讓子技能提供專業的測試指引
  1. ✅ Match corresponding sub-skills based on user needs
  2. ✅ Use the
    Skill
    tool to load specific sub-skills
  3. ✅ Let the sub-skills provide professional testing guidance

禁止行為

Prohibited Actions

  • ❌ 不要在本入口 skill 中直接提供測試程式碼
  • ❌ 不要在沒有載入子技能的情況下開始實作測試
  • ❌ 不要跳過子技能直接提供「一般性」測試建議

  • ❌ Do not directly provide test code in this entry skill
  • ❌ Do not start implementing tests without loading sub-skills
  • ❌ Do not skip sub-skills to provide "general" testing recommendations

🎯 快速技能對照表(AI Agent 必讀)

🎯 Quick Skill Reference Table (Must-Read for AI Agents)

使用者提到的關鍵字 → 應載入的子技能
Keywords mentioned by users → Sub-skills to load

最常用技能(必須熟記)

Most Frequently Used Skills (Must Memorize)

使用者說...載入指令用途說明
Validator、驗證器、CreateUserValidator
/skill dotnet-testing-fluentvalidation-testing
FluentValidation 測試
Mock、模擬、IRepository、IService
/skill dotnet-testing-nsubstitute-mocking
模擬外部依賴
AutoFixture、測試資料生成
/skill dotnet-testing-autofixture-basics
自動產生測試資料
斷言、Should()、BeEquivalentTo
/skill dotnet-testing-awesome-assertions-guide
流暢斷言(必學)
DateTime、時間測試、TimeProvider
/skill dotnet-testing-datetime-testing-timeprovider
時間相關測試
File、檔案系統、IFileSystem
/skill dotnet-testing-filesystem-testing-abstractions
檔案系統測試
Bogus、假資料、Faker
/skill dotnet-testing-bogus-fake-data
擬真資料生成
Builder Pattern、WithXxx
/skill dotnet-testing-test-data-builder-pattern
Test Data Builder
深層比對、DTO 比對、Excluding
/skill dotnet-testing-complex-object-comparison
複雜物件比對
User says...Load CommandPurpose
Validator, validator, CreateUserValidator
/skill dotnet-testing-fluentvalidation-testing
FluentValidation Testing
Mock, mocking, IRepository, IService
/skill dotnet-testing-nsubstitute-mocking
Mock external dependencies
AutoFixture, test data generation
/skill dotnet-testing-autofixture-basics
Automatically generate test data
Assertion, Should(), BeEquivalentTo
/skill dotnet-testing-awesome-assertions-guide
Fluent Assertions (Essential to Learn)
DateTime, time testing, TimeProvider
/skill dotnet-testing-datetime-testing-timeprovider
Time-related testing
File, file system, IFileSystem
/skill dotnet-testing-filesystem-testing-abstractions
File system testing
Bogus, fake data, Faker
/skill dotnet-testing-bogus-fake-data
Realistic fake data generation
Builder Pattern, WithXxx
/skill dotnet-testing-test-data-builder-pattern
Test Data Builder
Deep comparison, DTO comparison, Excluding
/skill dotnet-testing-complex-object-comparison
Complex object comparison

基礎入門技能

Basic Entry-Level Skills

使用者說...載入指令用途說明
從零開始、測試基礎、FIRST 原則
/skill dotnet-testing-unit-test-fundamentals
單元測試基礎
測試命名、如何命名測試
/skill dotnet-testing-test-naming-conventions
命名規範
建立測試專案、xUnit 設定
/skill dotnet-testing-xunit-project-setup
專案建置
User says...Load CommandPurpose
Start from scratch, testing fundamentals, FIRST principles
/skill dotnet-testing-unit-test-fundamentals
Unit testing fundamentals
Test naming, how to name tests
/skill dotnet-testing-test-naming-conventions
Naming conventions
Create test project, xUnit setup
/skill dotnet-testing-xunit-project-setup
Project setup

進階技能組合

Advanced Skill Combinations

使用者說...載入指令用途說明
AutoFixture + Bogus
/skill dotnet-testing-autofixture-bogus-integration
自動化+擬真資料
AutoFixture + NSubstitute
/skill dotnet-testing-autofixture-nsubstitute-integration
自動建立 Mock
AutoData、Theory 測試
/skill dotnet-testing-autodata-xunit-integration
參數化測試
測試輸出、ITestOutputHelper
/skill dotnet-testing-test-output-logging
測試日誌
覆蓋率、Coverlet
/skill dotnet-testing-code-coverage-analysis
程式碼覆蓋率

User says...Load CommandPurpose
AutoFixture + Bogus
/skill dotnet-testing-autofixture-bogus-integration
Automation + realistic data
AutoFixture + NSubstitute
/skill dotnet-testing-autofixture-nsubstitute-integration
Automatically create Mocks
AutoData, Theory testing
/skill dotnet-testing-autodata-xunit-integration
Parameterized testing
Test output, ITestOutputHelper
/skill dotnet-testing-test-output-logging
Test logging
Coverage, Coverlet
/skill dotnet-testing-code-coverage-analysis
Code coverage analysis

⚠️ 使用流程範例

⚠️ Usage Flow Examples

✅ 正確流程

✅ Correct Flow

使用者:請幫我建立 CreateUserValidator 的測試

AI:我注意到您需要測試 Validator。根據快速對照表,
    我應該載入 dotnet-testing-fluentvalidation-testing skill。

    [使用 Skill tool 載入子技能]

AI:現在按照 FluentValidation Testing skill 的指引為您建立測試...
User: Please help me create tests for CreateUserValidator

AI: I notice you need to test Validators. According to the quick reference table,
    I should load the dotnet-testing-fluentvalidation-testing skill.

    [Use Skill tool to load sub-skill]

AI: Now I will create tests for you following the guidelines from the FluentValidation Testing skill...

❌ 錯誤流程

❌ Incorrect Flow

使用者:請幫我建立 CreateUserValidator 的測試

AI:好的,我來寫測試...(直接開始寫程式碼,沒有載入子技能)

User: Please help me create tests for CreateUserValidator

AI: Sure, I'll write the tests for you... (starts writing code directly without loading sub-skills)

📚 完整技能清單

📚 Complete Skill List

如需查看完整的 19 個基礎技能清單、詳細決策樹、學習路徑建議,請繼續閱讀本檔案後續內容。
人類開發者參考:如需快速查找,請查看 SKILLS_QUICK_INDEX.md

To view the complete list of 19 basic skills, detailed decision trees, and learning path recommendations, please continue reading the rest of this document.
For human developers reference: For quick lookup, please check SKILLS_QUICK_INDEX.md

適用情境

Applicable Scenarios

當您遇到以下情況時,我會協助您找到正確的技能:
  • 剛開始學習 .NET 測試,不知從何下手
  • 想為現有專案建立測試,需要完整指引
  • 需要改善測試品質,尋找最佳實踐
  • 遇到特定測試場景,不確定該用哪個工具
  • 想了解測試資料生成、斷言、模擬等技術
  • 希望提升測試可讀性與維護性
  • 需要處理時間、檔案系統等特殊測試場景
I will help you find the right skill when you encounter the following situations:
  • Just starting to learn .NET testing and don't know where to begin
  • Want to create tests for an existing project and need complete guidance
  • Need to improve test quality and look for best practices
  • Encounter specific testing scenarios and are unsure which tool to use
  • Want to learn about test data generation, assertions, mocking, and other techniques
  • Hope to improve test readability and maintainability
  • Need to handle special testing scenarios such as time, file systems, etc.

快速決策樹

Quick Decision Tree

我應該從哪裡開始?

Where should I start?

情境 1:完全新手,從未寫過測試

Scenario 1: Complete beginner, never written tests before

推薦學習路徑
  1. dotnet-testing-unit-test-fundamentals
    - 理解 FIRST 原則與 3A Pattern
  2. dotnet-testing-test-naming-conventions
    - 學習命名規範
  3. dotnet-testing-xunit-project-setup
    - 建立第一個測試專案
為什麼這樣學
  • FIRST 原則是所有測試的基礎,先建立正確的觀念
  • 命名規範讓測試易讀易維護
  • 實際動手建立專案,將理論轉化為實踐

Recommended Learning Path:
  1. dotnet-testing-unit-test-fundamentals
    - Understand FIRST principles and 3A Pattern
  2. dotnet-testing-test-naming-conventions
    - Learn naming conventions
  3. dotnet-testing-xunit-project-setup
    - Create your first test project
Why learn this way:
  • FIRST principles are the foundation of all testing, establish correct concepts first
  • Naming conventions make tests readable and maintainable
  • Actually create a project to turn theory into practice

情境 2:會寫基礎測試,但測試資料準備很麻煩

Scenario 2: Can write basic tests but preparing test data is cumbersome

推薦技能(擇一或組合)
選項 A - 自動化優先
dotnet-testing-autofixture-basics
適合:需要大量測試資料、減少樣板程式碼
選項 B - 擬真資料優先
dotnet-testing-bogus-fake-data
適合:需要真實感的測試資料(姓名、地址、Email 等)
選項 C - 語意清晰優先
dotnet-testing-test-data-builder-pattern
適合:需要高可讀性、明確表達測試意圖
選項 D - 兩者兼具
dotnet-testing-autofixture-basics
+
dotnet-testing-autofixture-bogus-integration
適合:同時需要自動化和擬真資料

Recommended Skills (choose one or combine):
Option A - Automation First
dotnet-testing-autofixture-basics
Suitable for: Need large amounts of test data, reduce boilerplate code
Option B - Realistic Data First
dotnet-testing-bogus-fake-data
Suitable for: Need realistic test data (names, addresses, emails, etc.)
Option C - Semantic Clarity First
dotnet-testing-test-data-builder-pattern
Suitable for: Need high readability, clearly express test intent
Option D - Best of Both Worlds
dotnet-testing-autofixture-basics
+
dotnet-testing-autofixture-bogus-integration
Suitable for: Need both automation and realistic data

情境 3:有外部依賴(資料庫、API、第三方服務)需要模擬

Scenario 3: Have external dependencies (databases, APIs, third-party services) that need mocking

推薦技能組合
  1. dotnet-testing-nsubstitute-mocking
    - NSubstitute Mock 框架基礎
  2. dotnet-testing-autofixture-nsubstitute-integration
    - (可選)整合 AutoFixture 與 NSubstitute
何時需要第二個技能
  • 如果您已經在使用 AutoFixture 產生測試資料
  • 想要自動建立 Mock 物件,減少手動設定

Recommended Skill Combination:
  1. dotnet-testing-nsubstitute-mocking
    - NSubstitute Mock framework basics
  2. dotnet-testing-autofixture-nsubstitute-integration
    - (Optional) Integrate AutoFixture with NSubstitute
When to use the second skill:
  • If you are already using AutoFixture to generate test data
  • Want to automatically create Mock objects and reduce manual configuration

情境 4:測試中有特殊場景

Scenario 4: Have special scenarios in testing

時間相關測試
dotnet-testing-datetime-testing-timeprovider
處理:DateTime.Now、時區轉換、時間計算
檔案系統測試
dotnet-testing-filesystem-testing-abstractions
處理:檔案讀寫、目錄操作、路徑處理
私有/內部成員測試
dotnet-testing-private-internal-testing
處理:需要測試 private、internal 成員(但應謹慎使用)

Time-related Testing
dotnet-testing-datetime-testing-timeprovider
Handles: DateTime.Now, time zone conversion, time calculations
File System Testing
dotnet-testing-filesystem-testing-abstractions
Handles: File reading/writing, directory operations, path handling
Private/Internal Member Testing
dotnet-testing-private-internal-testing
Handles: Need to test private, internal members (but use cautiously)

情境 5:需要更好的斷言方式

Scenario 5: Need better assertion methods

基礎需求 - 流暢斷言
dotnet-testing-awesome-assertions-guide
所有專案都應該使用,提升測試可讀性
進階需求 - 複雜物件比較
dotnet-testing-complex-object-comparison
處理:深層物件比較、DTO 驗證、Entity 比對
驗證規則測試
dotnet-testing-fluentvalidation-testing
處理:測試 FluentValidation 驗證器

Basic Need - Fluent Assertions
dotnet-testing-awesome-assertions-guide
Should be used in all projects to improve test readability
Advanced Need - Complex Object Comparison
dotnet-testing-complex-object-comparison
Handles: Deep object comparison, DTO validation, Entity comparison
Validation Rule Testing
dotnet-testing-fluentvalidation-testing
Handles: Testing FluentValidation validators

情境 6:想了解測試覆蓋率

Scenario 6: Want to learn about test coverage

dotnet-testing-code-coverage-analysis
學習:使用 Coverlet 分析程式碼覆蓋率、產生報告
dotnet-testing-code-coverage-analysis
Learn: Use Coverlet to analyze code coverage, generate reports

技能分類地圖

Skill Classification Map

將 19 個基礎技能分為 7 大類別(測試基礎、測試資料生成、測試替身、斷言驗證、特殊場景、測試度量、框架整合),每類包含技能對照表、學習路徑與程式碼範例。
📖 詳細內容請參閱 references/skill-classification-map.md
Divide 19 basic skills into 7 major categories (Testing Fundamentals, Test Data Generation, Test Doubles, Assertion Validation, Special Scenarios, Test Metrics, Framework Integration), each category includes a skill reference table, learning path, and code examples.
📖 For detailed content, please refer to references/skill-classification-map.md

常見任務映射表

Common Task Mapping Table

提供 7 個常見測試任務(從零建專案、服務依賴測試、時間邏輯測試等)的技能組合推薦、實施步驟與提示詞範例。
📖 詳細內容請參閱 references/task-mapping-table.md
Provides skill combination recommendations, implementation steps, and prompt examples for 7 common testing tasks (create project from scratch, service dependency testing, time logic testing, etc.).
📖 For detailed content, please refer to references/task-mapping-table.md

學習路徑建議

Learning Path Recommendations

規劃新手路徑(1-2 週)與進階路徑(2-3 週)的每日學習計畫,包含技能、學習重點與實作練習。
📖 詳細內容請參閱 references/learning-paths.md
Plans daily learning schedules for beginner paths (1-2 weeks) and advanced paths (2-3 weeks), including skills, learning focus, and practical exercises.
📖 For detailed content, please refer to references/learning-paths.md

引導對話範例

Guided Conversation Examples

展示 AI 如何與您互動,幫助您選擇正確的技能,包含新手入門、處理依賴、特定問題、改善測試等 4 個常見對話場景。
📖 詳細內容請參閱 references/conversation-examples.md
Demonstrates how AI interacts with you to help you choose the right skill, including 4 common conversation scenarios: beginner introduction, handling dependencies, specific problems, improving tests, etc.
📖 For detailed content, please refer to references/conversation-examples.md

與進階技能的關係

Relationship with Advanced Skills

完成基礎技能後,如果您需要進行整合測試、API 測試、容器化測試或微服務測試,請參考:
進階整合測試
dotnet-testing-advanced
  • ASP.NET Core 整合測試
  • 容器化測試(Testcontainers)
  • 微服務測試(.NET Aspire)
  • 測試框架升級與遷移
After completing the basic skills, if you need to perform integration testing, API testing, containerized testing, or microservices testing, please refer to:
Advanced Integration Testing
dotnet-testing-advanced
  • ASP.NET Core integration testing
  • Containerized testing (Testcontainers)
  • Microservices testing (.NET Aspire)
  • Testing framework upgrade and migration

相關資源

Related Resources

原始資料來源

Original Data Sources

學習文檔

Learning Documents

本技能集基於以下完整教材提煉而成:
  • Agent Skills:從架構設計到實戰應用 (docs/Agent_Skills_Mastery.pdf) 完整涵蓋 Agent Skills 從理論到實踐
  • Claude Code Skills: 讓 AI 變身專業工匠 (docs/Agent_Skills_Architecture.pdf) 深入解析 Agent Skills 的架構設計
  • .NET Testing:寫得更好、跑得更快 (docs/NET_Testing_Write_Better_Run_Faster.pdf) 測試執行優化與除錯技巧
This skill set is refined based on the following complete teaching materials:
  • Agent Skills: From Architecture Design to Practical Application (docs/Agent_Skills_Mastery.pdf) Fully covers Agent Skills from theory to practice
  • Claude Code Skills: Turn AI into a Professional Artisan (docs/Agent_Skills_Architecture.pdf) In-depth analysis of Agent Skills architecture design
  • .NET Testing: Write Better, Run Faster (docs/NET_Testing_Write_Better_Run_Faster.pdf) Test execution optimization and debugging techniques

下一步

Next Steps

選擇符合您需求的技能開始學習,或告訴我您的具體情況,我會推薦最適合的學習路徑!
快速開始
  • 新手 → 從
    dotnet-testing-unit-test-fundamentals
    開始
  • 有經驗 → 告訴我您遇到的具體問題
  • 不確定 → 告訴我您的專案情況,我會幫您分析
Choose the skill that meets your needs to start learning, or tell me your specific situation and I will recommend the most suitable learning path!
Quick Start:
  • Beginners → Start with
    dotnet-testing-unit-test-fundamentals
  • Experienced → Tell me the specific problem you encountered
  • Unsure → Tell me about your project and I will help you analyze it