test-data-patterns

Applies test data builder, object mother, and fixture patterns to C# unit tests.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/vnovakovits/claude-skills --skill test-data-patterns-vnovakovits
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-data-patterns
Source: https://github.com/vnovakovits/claude-skills/tree/main/plugins/engineering-practices/skills/test-data-patterns
Command: npx skills add https://github.com/vnovakovits/claude-skills --skill test-data-patterns-vnovakovits

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Test setup often dominates test bodies: constructors with a dozen parameters, copy-pasted arrangement code, and mystery-guest data make suites unreadable and hostile to refactoring. This Skill provides a catalog of test arrangement patterns that keep setup concise and tests readable as specifications. ## Core Features & Use Cases - Test Data Builder & Object Mother: Fluent builders with sensible defaults, semantic methods like IsScheduled(), and Mother factories that return pre-configured builders for named scenarios. - Structural Patterns: Arrange-Act-Assert, Given-When-Then, and chained Fixture.Given().When().Then() conventions for state-machine and event-sourced domains. - Arrangement Facades: A pattern that owns shared IDs, fake repository seeding, and command construction for handler tests where multiple fakes must coordinate. - Use Case: When adding a field to a command record breaks twenty test call sites, introduce an Arrangement so only the Command property changes while test methods stay untouched. ## Quick Start Ask Claude to review this test class and refactor the duplicated constructor setup into a test data builder with sensible defaults.

Frequently Asked Questions about test-data-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a test data builder in C#?▼

Create a sealed fluent class with sensible defaults for every field, WithX methods that return this for chaining, and a terminal Build() that returns a fresh production-type instance. Add semantic methods like IsScheduled() for repeated states and coordinated setters for coupled fields.

What is the difference between Object Mother and Test Data Builder?▼

An Object Mother is a static factory exposing named canonical scenarios, while a Test Data Builder constructs one type with customizable fields. The recommended combination has the Mother take identifying inputs and return a pre-configured Builder the test can further customize.

When should I use Arrange-Act-Assert vs Given-When-Then?▼

Use Arrange-Act-Assert as the default for state-based or output-based unit tests. Prefer Given-When-Then when verifying domain behavior, state transitions, or business rules, especially in event-sourced or behavior-oriented codebases where tests should read like specifications.

When should I not introduce a test data builder?▼

Skip a builder when a record with one or two fields is constructed directly with named arguments, or when the test is the only place that type is constructed. Builders earn their place with 4+ constructor parameters or construction duplicated across 3+ tests.

Why do my tests break every time the constructor changes?▼

Tests calling a many-parameter constructor directly cascade every signature change through the whole suite. Introduce a builder or Arrangement so construction lives in one place; only the Build() or Command property updates when the contract changes.

What is the mystery guest anti-pattern in unit tests?▼

A mystery guest is a test depending on data created elsewhere, such as shared fixture files or database seeds, hiding the starting state from the reader. Make the Given or Arrange phase explicit in each test, even at the cost of some repetition.