$npx -y skills add kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing.NET 測試基礎技能總覽與引導中心。當使用者詢問「如何寫 .NET 測試」、「.NET 測試入門」、「需要哪些測試工具」、「測試最佳實踐」、「從零開始學測試」等一般性測試需求時觸發。會根據具體需求推薦適合的子技能組合,涵蓋測試基礎、測試資料、斷言、模擬、特殊場景等 19 個基礎技能。 Make sure to use this skill whenever the user asks about .NET testing in general, wants to know which testing tool to use, or needs guid
| 1 | # .NET 測試基礎技能總覽 |
| 2 | |
| 3 | 本檔案是「導航中心」,幫助找到正確的子技能。子技能包含詳細的程式碼範例、最佳實踐和常見陷阱,載入正確的子技能能確保使用者獲得最完整的指引。 |
| 4 | |
| 5 | 根據使用者需求匹配對應的子技能,使用 Skill tool 載入,讓子技能提供專業的測試指引。 |
| 6 | |
| 7 | --- |
| 8 | |
| 9 | ## 快速技能對照表 |
| 10 | |
| 11 | **使用者提到的關鍵字 → 應載入的子技能** |
| 12 | |
| 13 | ### 最常用技能 |
| 14 | |
| 15 | | 使用者說... | 載入指令 | 用途說明 | |
| 16 | |------------|----------|----------| |
| 17 | | **Validator**、驗證器、CreateUserValidator | `/skill dotnet-testing-fluentvalidation-testing` | FluentValidation 測試 | |
| 18 | | **Mock**、模擬、IRepository、IService | `/skill dotnet-testing-nsubstitute-mocking` | 模擬外部依賴 | |
| 19 | | **AutoFixture**、測試資料生成 | `/skill dotnet-testing-autofixture-basics` | 自動產生測試資料 | |
| 20 | | **斷言**、Should()、BeEquivalentTo | `/skill dotnet-testing-awesome-assertions-guide` | 流暢斷言(必學) | |
| 21 | | **DateTime**、時間測試、TimeProvider | `/skill dotnet-testing-datetime-testing-timeprovider` | 時間相關測試 | |
| 22 | | **File**、檔案系統、IFileSystem | `/skill dotnet-testing-filesystem-testing-abstractions` | 檔案系統測試 | |
| 23 | | **Bogus**、假資料、Faker | `/skill dotnet-testing-bogus-fake-data` | 擬真資料生成 | |
| 24 | | **Builder Pattern**、WithXxx | `/skill dotnet-testing-test-data-builder-pattern` | Test Data Builder | |
| 25 | | **深層比對**、DTO 比對、Excluding | `/skill dotnet-testing-complex-object-comparison` | 複雜物件比對 | |
| 26 | |
| 27 | ### 基礎入門技能 |
| 28 | |
| 29 | | 使用者說... | 載入指令 | 用途說明 | |
| 30 | |------------|----------|----------| |
| 31 | | **從零開始**、測試基礎、FIRST 原則 | `/skill dotnet-testing-unit-test-fundamentals` | 單元測試基礎 | |
| 32 | | **測試命名**、如何命名測試 | `/skill dotnet-testing-test-naming-conventions` | 命名規範 | |
| 33 | | **建立測試專案**、xUnit 設定 | `/skill dotnet-testing-xunit-project-setup` | 專案建置 | |
| 34 | |
| 35 | ### 進階技能組合 |
| 36 | |
| 37 | | 使用者說... | 載入指令 | 用途說明 | |
| 38 | |------------|----------|----------| |
| 39 | | AutoFixture 自訂規則 | `/skill dotnet-testing-autofixture-customization` | ISpecimenBuilder 客製化 | |
| 40 | | AutoFixture + Bogus | `/skill dotnet-testing-autofixture-bogus-integration` | 自動化+擬真資料 | |
| 41 | | AutoFixture + NSubstitute | `/skill dotnet-testing-autofixture-nsubstitute-integration` | 自動建立 Mock | |
| 42 | | AutoData、Theory 測試 | `/skill dotnet-testing-autodata-xunit-integration` | 參數化測試 | |
| 43 | | 測試輸出、ITestOutputHelper | `/skill dotnet-testing-test-output-logging` | 測試日誌 | |
| 44 | | 覆蓋率、Coverlet | `/skill dotnet-testing-code-coverage-analysis` | 程式碼覆蓋率 | |
| 45 | |
| 46 | --- |
| 47 | |
| 48 | ## 使用流程範例 |
| 49 | |
| 50 | ``` |
| 51 | 使用者:請幫我建立 CreateUserValidator 的測試 |
| 52 | |
| 53 | AI:我注意到您需要測試 Validator。根據快速對照表, |
| 54 | 我應該載入 dotnet-testing-fluentvalidation-testing skill。 |
| 55 | |
| 56 | [使用 Skill tool 載入子技能] |
| 57 | |
| 58 | AI:現在按照 FluentValidation Testing skill 的指引為您建立測試... |
| 59 | ``` |
| 60 | |
| 61 | --- |
| 62 | |
| 63 | ## 完整技能清單 |
| 64 | |
| 65 | 如需查看完整的 19 個基礎技能清單、詳細決策樹、學習路徑建議,請繼續閱讀本檔案後續內容。 |
| 66 | |
| 67 | --- |
| 68 | |
| 69 | ## 快速決策樹 |
| 70 | |
| 71 | ### 我應該從哪裡開始? |
| 72 | |
| 73 | #### 情境 1:完全新手,從未寫過測試 |
| 74 | |
| 75 | **推薦學習路徑**: |
| 76 | 1. `dotnet-testing-unit-test-fundamentals` - 理解 FIRST 原則與 3A Pattern |
| 77 | 2. `dotnet-testing-test-naming-conventions` - 學習命名規範 |
| 78 | 3. `dotnet-testing-xunit-project-setup` - 建立第一個測試專案 |
| 79 | |
| 80 | **為什麼這樣學**: |
| 81 | - FIRST 原則是所有測試的基礎,先建立正確的觀念 |
| 82 | - 命名規範讓測試易讀易維護 |
| 83 | - 實際動手建立專案,將理論轉化為實踐 |
| 84 | |
| 85 | --- |
| 86 | |
| 87 | #### 情境 2:會寫基礎測試,但測試資料準備很麻煩 |
| 88 | |
| 89 | **推薦技能(擇一或組合)**: |
| 90 | |
| 91 | **選項 A - 自動化優先** |
| 92 | → `dotnet-testing-autofixture-basics` |
| 93 | 適合:需要大量測試資料、減少樣板程式碼 |
| 94 | |
| 95 | **選項 B - 擬真資料優先** |
| 96 | → `dotnet-testing-bogus-fake-data` |
| 97 | 適合:需要真實感的測試資料(姓名、地址、Email 等) |
| 98 | |
| 99 | **選項 C - 語意清晰優先** |
| 100 | → `dotnet-testing-test-data-builder-pattern` |
| 101 | 適合:需要高可讀性、明確表達測試意圖 |
| 102 | |
| 103 | **選項 D - 兩者兼具** |
| 104 | → `dotnet-testing-autofixture-basics` + `dotnet-testing-autofixture-bogus-integration` |
| 105 | 適合:同時需要自動化和擬真資料 |
| 106 | |
| 107 | --- |
| 108 | |
| 109 | #### 情境 3:有外部依賴(資料庫、API、第三方服務)需要模擬 |
| 110 | |
| 111 | **推薦技能組合**: |
| 112 | 1. `dotnet-testing-nsubstitute-mocking` - NSubstitute Mock 框架基礎 |
| 113 | 2. `dotnet-testing-autofixture-nsubstitute-integration` - (可選)整合 AutoFixture 與 NSubstitute |
| 114 | |
| 115 | **何時需要第二個技能**: |
| 116 | - 如果您已經在使用 AutoFixture 產生測試資料 |
| 117 | - 想要自動建立 Mock 物件,減少手動設定 |
| 118 | |
| 119 | --- |
| 120 | |
| 121 | #### 情境 4:測試中有特殊場景 |
| 122 | |
| 123 | **時間相關測試** |
| 124 | → `dotnet-testing-datetime-testing-timeprovider` |
| 125 | 處理:DateTime.Now、時區轉換、時間計算 |
| 126 | |
| 127 | **檔案系統測試** |
| 128 | → `dotnet-testing-filesystem-testing-abstractions` |
| 129 | 處理:檔案讀寫、目錄操作、路徑處理 |
| 130 | |
| 131 | **私有/內部成員測試** |
| 132 | → `dotnet-testing-private-internal-testing` |
| 133 | 處理:需要測試 private、internal 成員(但應謹慎使用) |
| 134 | |
| 135 | --- |
| 136 | |
| 137 | #### 情境 5:需要更好的斷言方式 |
| 138 | |
| 139 | **基礎需求 - 流暢斷言** |
| 140 | → `dotnet-testing-awesome-assertions-guide` |
| 141 | 所有專案都應該使用,提升測試可讀性 |
| 142 | |
| 143 | **進階需求 - 複雜物件比較** |
| 144 | → `dotnet-testing-complex-object-comparison` |
| 145 | 處理:深層物件比較、DTO 驗證、Entity 比對 |
| 146 | |
| 147 | **驗證規則測試** |
| 148 | → `dotnet-testing-fluentvalidation-testing` |
| 149 | 處理:測試 FluentValidation 驗證器 |
| 150 | |
| 151 | --- |
| 152 | |
| 153 | #### 情境 6:想了解測試覆蓋率 |
| 154 | |
| 155 | → `dotnet-testing-code-coverage-analysis` |
| 156 | 學習:使用 Coverlet 分析程式碼覆蓋率、產生報告 |
| 157 | |
| 158 | ## 技能分類地圖 |
| 159 | |
| 160 | 將 19 個基礎技能分為 7 大類別(測試基礎、測試資料生成、測試替身、斷言驗證、特殊場景、測試度量、框架整合),每類包含技能對照表、學習路徑與程式碼範例。 |
| 161 | |
| 162 | > 詳細內容請參閱 [references/skill-classification-map.md](references/skill-classification-map.md) |
| 163 | |
| 164 | ## 常見任務映射表 |
| 165 | |
| 166 | 提供 7 個常見測試任務(從零建專案、服務依賴測試、時間邏輯測試等)的技能組合推薦、實施步驟與提示詞範例。 |
| 167 | |
| 168 | > 詳細內容請參閱 [references/task-mapping-table.md](references/task- |