DDD Testing Standards

Enforce DDD testing standards across domain, application, and integration layers.

Updated Oct 31, 2025
One-click install
npx skills add https://github.com/RomualdP/hoki --skill ddd-testing-standards
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: DDD Testing Standards
Source: https://github.com/RomualdP/hoki/tree/main/.claude/skills/ddd-testing
Command: npx skills add https://github.com/RomualdP/hoki --skill ddd-testing-standards

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jest, @nestjs/testing, prisma.

What problem does it solve?

This Skill establishes a robust testing methodology for Domain-Driven Design (DDD) backend applications, ensuring critical business logic is thoroughly validated and preventing regressions. It enforces strict coverage requirements and promotes a Test-Driven Development (TDD) approach.

Core Features & Use Cases

  • Layered Testing: Guides on creating unit tests for Domain Entities and Value Objects (100% coverage mandatory), Application Layer handlers (95%+ coverage), and integration tests for critical workflows.
  • TDD Workflow: Promotes a Red-Green-Refactor cycle, ensuring tests are written before implementation, leading to more reliable and well-documented code.
  • Coverage Enforcement: Defines strict code coverage thresholds for different layers, integrated into jest.config.js and CI/CD pipelines.
  • Use Case: When developing a new DDD bounded context, use this Skill to structure your test suite, write comprehensive tests for your domain logic, and ensure high code quality before deployment.

Quick Start

To test a new domain entity, create a *.spec.ts file in tests/unit/domain/entities/ and write a failing test for a business method. Then, implement the minimal code to make the test pass, and refactor while keeping the test green.

Frequently Asked Questions about DDD Testing Standards

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

FAQPage Schema
How do I achieve 100% code coverage for domain logic in a DDD backend?

DDD testing requires exhaustive unit tests for domain entities and value objects with 100% coverage mandatory, plus integration tests for critical workflows. Write tests for all business methods, validations, state transitions, edge cases, invariants, and factory methods before implementation using a Test-Driven Development cycle.

What's the best way to structure unit tests across domain, application, and integration layers?

Organize tests into layers: unit tests for domain entities and value objects in `tests/unit/domain/entities/`, application layer tests at 95%+ coverage, and integration tests for workflows. Use `*.spec.ts` naming convention and configure coverage thresholds in `jest.config.js` for each layer.

How do I implement Test-Driven Development for a new DDD bounded context?

Follow the Red-Green-Refactor cycle: write a failing test for a business method first, implement minimal code to pass the test, then refactor while keeping tests green. This approach produces reliable, well-documented code with comprehensive business logic validation.

Can I use Jest and NestJS testing with DDD testing standards?

Yes. Jest and @nestjs/testing are the testing frameworks for this DDD testing methodology. Integrate coverage enforcement into `jest.config.js` and CI/CD pipelines to enforce strict thresholds across domain, application, and integration layers.

Why enforce code coverage requirements in DDD testing workflows?

Strict coverage thresholds prevent regressions in critical business logic and ensure all invariants, validations, and state transitions are tested. This rigor is essential in DDD where domain entities and value objects encode core business rules.

What edge cases and invariants must I test in domain entities?

Test all business method behaviors, validation rules, state transitions, edge cases, and invariants defined in your domain model. Include factory method testing to ensure entities initialize correctly and satisfy domain constraints.