dotnet-testing-test-data-builder-pattern

dotnet-testing-test-data-builder-pattern is a skill for Claude Code, Codex from kevintsengtw/dotnet-testing-agent-skills. It costs 145 tokens per session (1,720 once invoked), scanned A, original, MIT.

A guide to the Test Data Builder pattern, a way to create test objects from sensible defaults while changing only the fields relevant to each test. It uses readable builder methods such as setting a name or creating an administrator user.

In plain words
What is it for?
Use it to build complex test data, create common scenarios, override selected properties, combine builders for related objects, and reuse test-data setup.
Why use it?
It keeps test setup short and makes the purpose of each test easier to see, instead of repeating long object definitions.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to build complex test data, create common scenarios, override selected properties, combine builders for related objects, and reuse test-data setup.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-pattern
Install

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.

Any agent
npx skills add kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-test-data-builder-pattern
Clone the repo
git clone --depth 1 https://github.com/kevintsengtw/dotnet-testing-agent-skills

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for dotnet-testing-test-data-builder-pattern

README.md
[![agentmods](https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-pattern/github.svg)](https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-test-data-builder-pattern)
Your own site
<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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dotnet-testing-test-data-builder-pattern

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 145 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,720 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00145 $0.01720
Opus 5.5 $0.00058 $0.00688
Sonnet 5.5 $0.00029 $0.00344
Haiku 4.5 $0.00015 $0.00172

Measured 22d ago against content hash 2ec09ab26342, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 22d 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.

skills/dotnet-testing-test-data-builder-pattern/SKILL.md · 125 lines

How it starts

The opening of the file, as written. The whole thing — 125 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 的改良版,主要解決以下問題:

  1. 固定測試資料的問題:Object Mother 提供固定的測試物件,難以針對特定測試情境調整
  2. 測試意圖不明確:直接建立物件時,測試的關注點容易被大量屬性設定所掩蓋
  3. 重複程式碼:相似的物件建立邏輯在多個測試中重複出現

為何需要 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 應包含:

  1. 預設值:為所有必要屬性提供合理的預設值
  2. 流暢介面:使用 With* 方法鏈來設定屬性
  3. 語意化方法:提供有意義的預設建立者(如 AnAdminUser()、ARegularUser())
  4. 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 幾乎零設定
測試意圖 非常明確 需額外說明
適用時機 需要精確控制的測試 大量資料產生、匿名測試

Read the full file on GitHub · 125 lines

Files

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.

Changes

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.

  1. 22d ago Changed · -1 lines · -42 tokens per session 2ec09ab26342
  2. 1mo ago First seen · 126 lines · 187 tokens per session scan A 9353484a5c25

Subscribe to this mod's changes

dotnet-testing-test-data-builder-pattern is a skill published in the GitHub repository kevintsengtw/dotnet-testing-agent-skills (30 stars, last pushed 18d ago), licensed MIT. It adds 145 tokens to every session and 1,720 once invoked, about $0.0006 per session on Opus 5.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.

Related

Other skills, from other repositories