Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Pascal
  3. Delphi-Mocks

Delphi-Mocks

Apache-2.0Pascalv0.3.1

A mocking framework for Delphi XE2+ that uses RTTI to create test doubles for unit testing.

Visit WebsiteGitHubGitHub
251 stars114 forks0 contributors

What is Delphi-Mocks?

Delphi Mocks is an open-source mocking framework for Delphi XE2 and later versions. It allows developers to create mock objects, stubs, and spies for unit testing by utilizing Delphi's RTTI features, helping to isolate dependencies and verify code interactions. The framework simplifies testing Delphi applications by providing a fluent API for setting expectations and behavior.

Target Audience

Delphi developers using XE2 or later who practice unit testing, TDD (Test-Driven Development), or need to mock dependencies in their Object Pascal codebases.

Value Proposition

Developers choose Delphi Mocks because it integrates seamlessly with Delphi's RTTI, reducing manual mock implementation overhead. Its rich parameter matching and intuitive API make it a practical, lightweight alternative to hand-rolled test doubles or commercial mocking tools for Delphi.

Overview

A Open Source Mocking framework for Delphi XE2 or later

Use Cases

Best For

  • Unit testing Delphi applications with complex dependencies
  • Mocking interfaces and classes in Delphi XE2+ projects
  • Implementing TDD practices in Object Pascal codebases
  • Verifying method call interactions in automated tests
  • Isolating external services or components during testing
  • Reducing boilerplate code for test doubles in Delphi

Not Ideal For

  • Projects using Delphi versions older than XE2, as it requires RTTI features only available from XE2 onward
  • Teams preferring commercial mocking tools with GUI test designers or extensive IDE integration
  • Codebases heavily reliant on static methods or non-RTTI classes, where mocking capabilities may be limited
  • Applications where zero runtime overhead is critical, as RTTI-based mocking can introduce performance costs

Pros & Cons

Pros

RTTI-Powered Simplicity

Leverages Delphi's native RTTI to automatically generate mocks, eliminating manual interface implementations and reducing boilerplate code for test doubles.

Rich Parameter Matching

Offers extensive matchers like IsAny, IsEqualTo, IsRegex, and IsInRange, enabling precise and flexible expectation setup in unit tests.

Fluent Setup API

Provides an intuitive, chainable API (e.g., mock.Setup.Expect.AtLeastOnce.When.Method) that makes configuring mocks and expectations straightforward and readable.

Dual Interface and Class Support

Handles mocking for both interfaces and classes, with specific guidance to address class matching quirks, enhancing versatility in Delphi testing.

Cons

Class Matching Quirks

Has non-intuitive behavior with IsAny for classes, requiring IsNotNil to avoid nil conflicts, which can lead to setup errors and increased complexity.

Delphi Version Lock-In

Limited to Delphi XE2 and later, excluding legacy projects or teams on older versions, and may not keep pace with the latest Delphi releases.

Sparse Ecosystem and Documentation

As a niche framework, it lacks extensive community examples, third-party integrations, and detailed documentation beyond basic usage snippets.

Frequently Asked Questions

Quick Stats

Stars251
Forks114
Contributors0
Open Issues7
Last commit3 months ago
CreatedSince 2011

Tags

#software-testing#unit-testing#object-pascal#rtti#delphi-xe2#tdd#test-doubles#delphi#dpmpackage#mocking-framework

Built With

D
Delphi
O
Object Pascal

Links & Resources

Website

Included in

Pascal2.0k
Auto-fetched 9 hours ago

Related Projects

DUnitXDUnitX

Delphi Unit Test Framework

Stars423
Forks217
Last commit15 days ago
DelphiUIAutomationDelphiUIAutomation

Delphi classes the wrap the MS UIAutomation library

Stars115
Forks46
Last commit9 years ago
DelphiSpecDelphiSpec

Delphi library for running automated tests written in plain language

Stars72
Forks27
Last commit10 years ago
SmoketestSmoketest

Deltics Delphi.libs is a comprehensive collection of libraries for the Delphi programming language, providing a diverse array of reusable functionality for Windows development. It includes the Smoketest testing framework, enabling developers to write and run tests and performance benchmarks efficiently. ## Key Features - **Smoketest Framework** — Integrated testing and performance benchmarking framework for Delphi applications. - **Reusable Components** — A collection of highly reusable classes, functions, and utilities across multiple libraries. - **Core RTL Library** — Foundational library with essential classes and functions required by other components in the collection. - **Stand-alone Libraries** — Some libraries operate independently, while others have dependencies for extended functionality. - **Compatibility** — Tested and compatible with Delphi versions from 7 through to 2010 on Microsoft Windows. ## Philosophy The project emphasizes modularity and reusability, with a focus on providing robust, tested components that simplify Delphi development for Windows platforms.

Stars51
Forks13
Last commit9 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub