create-test-builder

Generates Test Data Builder and Object Mother patterns for PHP 8.4. Creates fluent builders with sensible defaults and factory methods for test data creation.

59 stars

Best use case

create-test-builder is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generates Test Data Builder and Object Mother patterns for PHP 8.4. Creates fluent builders with sensible defaults and factory methods for test data creation.

Teams using create-test-builder should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/create-test-builder/SKILL.md --create-dirs "https://raw.githubusercontent.com/dykyi-roman/awesome-claude-code/main/skills/create-test-builder/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/create-test-builder/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How create-test-builder Compares

Feature / Agentcreate-test-builderStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generates Test Data Builder and Object Mother patterns for PHP 8.4. Creates fluent builders with sensible defaults and factory methods for test data creation.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Test Data Builder Generator

Generates Test Data Builder and Object Mother patterns for test data creation.

## Patterns

### Test Data Builder

Fluent interface for constructing test objects with customizable properties.

**When to use:**
- Complex objects with many properties
- Need to customize specific properties per test
- Want to express test intent clearly

### Object Mother

Factory methods returning pre-configured objects for common scenarios.

**When to use:**
- Standard test fixtures (default user, pending order)
- Shared across many tests
- Named scenarios (premium customer, expired subscription)

## References

- `references/templates.md` — Builder and Object Mother class templates
- `references/examples.md` — Complete Order example with Value Object builders and usage

## Generation Instructions

1. **Analyze the target class:**
   - Constructor parameters
   - Required vs optional properties
   - Value objects used
   - State transitions (for entities)

2. **Determine sensible defaults:**
   - Generate IDs automatically
   - Use common/valid values
   - Consider relationships

3. **Create Builder with:**
   - Private constructor with defaults
   - Static factory method (`aOrder`, `anEmail`)
   - `with*` methods for each property
   - Immutable (clone in each method)
   - `build()` method

4. **Create Mother with:**
   - `default()` method
   - Named scenarios (`pending`, `confirmed`, `premium`)
   - Parameterized methods (`forCustomer`, `withTotal`)

5. **File placement:**
   - Builders: `tests/Builder/{ClassName}Builder.php`
   - Mothers: `tests/Mother/{ClassName}Mother.php`

## Best Practices

1. **Sensible defaults** — Tests should work without customization
2. **Fluent interface** — Chain method calls
3. **Immutable builders** — Clone in each `with*` method
4. **Expressive names** — `pending()` not `withStatus(pending)`
5. **Composition** — Builders can use other Mothers/Builders
6. **Single Responsibility** — One builder per aggregate/entity

Related Skills

testing-knowledge

59
from dykyi-roman/awesome-claude-code

Testing knowledge base for PHP 8.4 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

suggest-testability-improvements

59
from dykyi-roman/awesome-claude-code

Suggests testability improvements for PHP code. Provides DI refactoring suggestions, mock opportunities, interface extraction, testing strategy recommendations.

detect-test-smells

59
from dykyi-roman/awesome-claude-code

Detects test antipatterns and code smells in PHP test suites. Identifies 15 smells (Logic in Test, Mock Overuse, Fragile Tests, Mystery Guest, etc.) with fix recommendations and refactoring patterns for testability.

create-visitor

59
from dykyi-roman/awesome-claude-code

Generates Visitor pattern for PHP 8.4. Creates operations on object structures without modifying element classes, with visitor interface, concrete visitors, and visitable elements. Includes unit tests.

create-value-object

59
from dykyi-roman/awesome-claude-code

Generates DDD Value Objects for PHP 8.4. Creates immutable, self-validating objects with equality comparison. Includes unit tests.

create-use-case

59
from dykyi-roman/awesome-claude-code

Generates Application Use Cases for PHP 8.4. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.

create-unit-test

59
from dykyi-roman/awesome-claude-code

Generates PHPUnit unit tests for PHP 8.4. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.

create-unit-of-work

59
from dykyi-roman/awesome-claude-code

Generates Unit of Work pattern components for PHP 8.4. Creates transactional consistency infrastructure with aggregate tracking, flush/rollback, domain event collection, and unit tests.

create-timeout

59
from dykyi-roman/awesome-claude-code

Generates Timeout pattern components for PHP 8.4. Creates execution time limit infrastructure with configurable timeouts, fallback support, stream timeouts, and unit tests.

create-test-double

59
from dykyi-roman/awesome-claude-code

Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.4. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.

create-template-method

59
from dykyi-roman/awesome-claude-code

Generates Template Method pattern for PHP 8.4. Creates abstract algorithm skeleton with customizable steps, allowing subclasses to override specific parts without changing structure. Includes unit tests.

create-structured-logger

59
from dykyi-roman/awesome-claude-code

Generates Structured Logger for PHP 8.4. Creates PSR-3 structured logging setup with Monolog processors, correlation ID propagation, and context middleware. Includes unit tests.