A mocking framework for Delphi XE2+ that uses RTTI to create test doubles for unit testing.
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.
Delphi developers using XE2 or later who practice unit testing, TDD (Test-Driven Development), or need to mock dependencies in their Object Pascal codebases.
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.
A Open Source Mocking framework for Delphi XE2 or later
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages Delphi's native RTTI to automatically generate mocks, eliminating manual interface implementations and reducing boilerplate code for test doubles.
Offers extensive matchers like IsAny, IsEqualTo, IsRegex, and IsInRange, enabling precise and flexible expectation setup in unit tests.
Provides an intuitive, chainable API (e.g., mock.Setup.Expect.AtLeastOnce.When.Method) that makes configuring mocks and expectations straightforward and readable.
Handles mocking for both interfaces and classes, with specific guidance to address class matching quirks, enhancing versatility in Delphi testing.
Has non-intuitive behavior with IsAny for classes, requiring IsNotNil to avoid nil conflicts, which can lead to setup errors and increased complexity.
Limited to Delphi XE2 and later, excluding legacy projects or teams on older versions, and may not keep pace with the latest Delphi releases.
As a niche framework, it lacks extensive community examples, third-party integrations, and detailed documentation beyond basic usage snippets.