Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-patternnpx skills add kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-test-data-builder-patterngit clone --depth 1 https://github.com/kevintsengtw/dotnet-testing-agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-pattern)<a href="https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-pattern"><img src="https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-pattern.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00187 | $0.01763 |
| Opus 5 | $0.00093 | $0.00881 |
| Sonnet 5 | $0.00037 | $0.00353 |
| Haiku 4.5 | $0.00019 | $0.00176 |
Grade A, and why
dotnet-testing-test-data-builder-pattern scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Test Data Builder Pattern 測試資料建構器模式
核心概念
什麼是 Test Data Builder Pattern?
Test Data Builder Pattern 是 Object Mother Pattern 的改良版,主要解決以下問題:
- 固定測試資料的問題:Object Mother 提供固定的測試物件,難以針對特定測試情境調整
- 測試意圖不明確:直接建立物件時,測試的關注點容易被大量屬性設定所掩蓋
- 重複程式碼:相似的物件建立邏輯在多個測試中重複出現
為何需要 Builder Pattern?
// ❌ 問題:過多參數設定,測試意圖不明確
var user = new User
{
Name = "John Doe", Email = "[email protected]", Age = 30,
Roles = new[] { "User" }, Settings = new UserSettings { Theme = "Dark", Language = "zh-TW" },
IsActive = true, CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now
};
// ✅ 改善:意圖明確,只設定測試關注的屬性
var user = UserBuilder.AUser().WithName("John Doe").WithValidEmail().Build();
實作指南
基本 Builder 結構
一個標準的 Test Data Builder 應包含:
- 預設值:為所有必要屬性提供合理的預設值
- 流暢介面:使用
With*方法鏈來設定屬性 - 語意化方法:提供有意義的預設建立者(如
AnAdminUser()、ARegularUser()) - Build 方法:最終建立並回傳目標物件
涵蓋完整 UserBuilder 實作(預設值、With* 流暢方法、語意化靜態工廠方法、Build 方法)、單一測試情境與配合 Theory 使用的範例。
完整 Builder 實作與測試使用範例請參考 references/builder-implementation.md
最佳實踐
涵蓋五項實踐:提供合理的預設值、使用語意化命名(UserScenarios)、Builder 之間的組合(OrderBuilder 組合 UserBuilder + ProductBuilder)、避免過度複雜化、統一管理測試資料(TestData 靜態類別)。
完整最佳實踐與進階模式請參考 references/best-practices-and-patterns.md
與其他模式的比較
Test Data Builder vs. Object Mother
| 特性 | Test Data Builder | Object Mother |
|---|---|---|
| 彈性 | 高度彈性,可針對測試調整 | 固定的測試資料 |
| 可讀性 | 流暢介面,意圖明確 | 需要查看方法實作 |
| 維護性 | 集中管理,易於修改 | 變更影響所有測試 |
| 使用場景 | 單元測試、情境測試 | 簡單的整合測試 |
Test Data Builder vs. AutoFixture
| 特性 | Test Data Builder | AutoFixture |
|---|---|---|
| 控制度 | 完全控制物件建立 | 自動產生,控制度較低 |
| 設定複雜度 | 需手動建立 Builder | 幾乎零設定 |
| 測試意圖 | 非常明確 | 需額外說明 |
| 適用時機 | 需要精確控制的測試 | 大量資料產生、匿名測試 |
What ships with it
5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 126 lines · 187 tokens per session scan A 9353484a5c25
dotnet-testing-test-data-builder-pattern is a skill published in the GitHub repository kevintsengtw/dotnet-testing-agent-skills (28 stars, last pushed 19d ago), licensed MIT. It adds 187 tokens to every session and 1,763 once invoked, about $0.0009 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
nunit-testing
Use when writing or modifying tests in NUnit's own test projects, or when making a behavioral change to production code that needs test coverage. Covers test structure, attribute choice, helper visibility, platform guards, and which test projects are real.
nunit-threading-and-async
Use when writing or modifying async code in NUnit — async test lifecycle (setup/teardown), TestExecutionContext, AsyncLocal, Task/ValueTask continuations, blocking vs non-blocking waits, or conditional Thread.Abort code. Covers the threading/async conventions the NUnit runtime depends on.
clean-architecture-dotnet
Use when domain logic leaks into API/Infrastructure, project references violate layer boundaries, or you need to decide between CQS (always), CQRS bus (complex domains), and DDD patterns (invariants and events).
creating-dotnet-mcp-servers
Use when building Model Context Protocol (MCP) servers in .NET, configuring tools, transports (SSE/stdio), JSON serialization for AOT, or testing MCP endpoints.
csharp-xunit
Get best practices for XUnit unit testing, including data-driven tests.
mcaf-dotnet-mstest
Write, run, or repair .NET tests that use MSTest. Use when a repo uses MSTest.Sdk, MSTest, [TestClass], [TestMethod], DataRow, or Microsoft.Testing.Platform-based MSTest execution.