DUnitX Testing Patterns

Organize Delphi unit tests with DUnitX fixtures, mocks, and naming conventions.

48|12|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/delphicleancode/delphi-spec-kit --skill dunitx-testing-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: DUnitX Testing Patterns
Source: https://github.com/delphicleancode/delphi-spec-kit/tree/main/.gemini/skills/dunitx-testing
Command: npx skills add https://github.com/delphicleancode/delphi-spec-kit --skill dunitx-testing-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The DUnitX Testing Patterns guide helps Delphi teams organize and standardize their unit tests using the DUnitX framework, aligning tests with best practices for fixtures, mocks, and clean architecture.

Core Features & Use Cases

  • Structured test fixtures with Setup and TearDown to isolate test state.
  • Use of mocks and in-memory or lightweight repositories to validate service behavior without real dependencies.
  • Guidelines for naming tests (MethodName_Scenario_ExpectedBehavior), common assertions, and practical integration testing strategies, including SQLite-in-memory demos.

Quick Start

Create a DUnitX test project under tests/, implement a TestFixture with Setup/TearDown, and add representative tests following the naming conventions.

Frequently Asked Questions about DUnitX Testing Patterns

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

FAQPage Schema
How do I structure Delphi unit tests using DUnitX?

Structure Delphi unit tests by creating a DUnitX test project under a tests directory and implementing TestFixture classes with Setup and TearDown methods to isolate test state. This pattern aligns tests with clean architecture best practices.

What is the naming convention for DUnitX test methods?

The naming convention for DUnitX test methods is MethodName_Scenario_ExpectedBehavior. This standardized format improves readability and helps Delphi teams quickly identify the test target, specific condition, and expected outcome.

Can I use mocks and in-memory repositories in Delphi integration testing?

Yes, you can use mocks and in-memory or lightweight repositories in Delphi integration testing to validate service behavior without real dependencies. The DUnitX patterns include SQLite-in-memory demos for practical integration testing strategies.

Do I need a specific directory structure for DUnitX testing patterns?

Yes, DUnitX testing patterns require a conventional tests directory containing TestFixture classes. You create the DUnitX test project under tests/ and implement fixtures with setup and teardown methods to properly isolate test state.

How does Setup and TearDown isolate test state in DUnitX?

Setup and TearDown isolate test state in DUnitX by executing initialization and cleanup methods around each test fixture. This ensures Delphi unit tests run independently without shared state or side effects from previous test executions.

When should I use integration testing instead of unit testing in Delphi?

Use integration testing in Delphi when you need to validate service behavior with lightweight repositories like SQLite-in-memory databases. Unit testing with mocks is preferred when validating isolated logic without real dependencies.