All Projects → VSoftTechnologies → Delphi Mocks

VSoftTechnologies / Delphi Mocks

Licence: apache-2.0
A Open Source Mocking framework for Delphi XE2 or later

Programming Languages

pascal
1382 projects
delphi
115 projects

Projects that are alternatives of or similar to Delphi Mocks

umock-c
A pure C mocking library
Stars: ✭ 29 (-84.32%)
Mutual labels:  mocking-framework
Mockk
mocking library for Kotlin
Stars: ✭ 4,214 (+2177.84%)
Mutual labels:  mocking-framework
Simplestubs
*SimpleStubs* is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs is currently developed and maintained by Microsoft BigPark Studios in Vancouver.
Stars: ✭ 66 (-64.32%)
Mutual labels:  mocking-framework
servirtium-java
Service Virtualized HTTP - to help service test automation stay fast and consistent
Stars: ✭ 16 (-91.35%)
Mutual labels:  mocking-framework
Powermock
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.
Stars: ✭ 3,708 (+1904.32%)
Mutual labels:  mocking-framework
Msw
Seamless REST/GraphQL API mocking library for browser and Node.js.
Stars: ✭ 7,830 (+4132.43%)
Mutual labels:  mocking-framework
IOS-CoreBluetooth-Mock
Mocking library for CoreBluetooth framework.
Stars: ✭ 142 (-23.24%)
Mutual labels:  mocking-framework
Cgreen
A modern, portable, cross-language unit testing and mocking framework for C and C++
Stars: ✭ 132 (-28.65%)
Mutual labels:  mocking-framework
Mimic
Seamless client side mocking
Stars: ✭ 380 (+105.41%)
Mutual labels:  mocking-framework
Pclmock
A simple mocking framework in a PCL.
Stars: ✭ 40 (-78.38%)
Mutual labels:  mocking-framework
mock-inspect
Mocks network requests and allows you to make assertions about how these requests happened. Supports auto-mocking of graphQL requests given a valid schema.
Stars: ✭ 19 (-89.73%)
Mutual labels:  mocking-framework
Mockolo
Efficient Mock Generator for Swift
Stars: ✭ 327 (+76.76%)
Mutual labels:  mocking-framework
Cpputest
CppUTest unit testing and mocking framework for C/C++
Stars: ✭ 896 (+384.32%)
Mutual labels:  mocking-framework
DMocks-revived
A mocking framework for the D programming language
Stars: ✭ 22 (-88.11%)
Mutual labels:  mocking-framework
Logginginterceptor
An OkHttp interceptor which has pretty logger for request and response. +Mock support
Stars: ✭ 1,149 (+521.08%)
Mutual labels:  mocking-framework
FSeam
Cpp header only library to manage compile time mock class generated via Python script
Stars: ✭ 84 (-54.59%)
Mutual labels:  mocking-framework
Kakapo.js
🐦 Next generation mocking framework in Javascript
Stars: ✭ 535 (+189.19%)
Mutual labels:  mocking-framework
Mockito
Most popular Mocking framework for unit tests written in Java
Stars: ✭ 12,453 (+6631.35%)
Mutual labels:  mocking-framework
Mockit
A simple mocking framework for Swift, inspired by the famous http://mockito.org/
Stars: ✭ 110 (-40.54%)
Mutual labels:  mocking-framework
Ocmockito
Mockito for Objective-C: creation, verification and stubbing of mock objects
Stars: ✭ 972 (+425.41%)
Mutual labels:  mocking-framework

Delphi Mocks

Delphi Mocks is a simple mocking framework for Delphi XE2 or later. It makes use of RTTI features that are only available in Delphi XE2, however I do hope to be able to get it working with earlier versions of Delphi (2010 or later) at some stage.

Example

unit Delphi.Mocks.Examples.Interfaces;

interface

uses
  SysUtils,
  DUnitX.TestFramework,
  Delphi.Mocks;

type
  {$M+}
  TSimpleInterface = Interface
    ['{4131D033-2D80-42B8-AAA1-3C2DF0AC3BBD}']
    procedure SimpleMethod;
  end;

  TSystemUnderTestInf = Interface
    ['{5E21CA8E-A4BB-4512-BCD4-22D7F10C5A0B}']
    procedure CallsSimpleInterfaceMethod;
  end;
  {$M-}

  TSystemUnderTest = class(TInterfacedObject, TSystemUnderTestInf)
  private
    FInternalInf : TSimpleInterface;
  public
    constructor Create(const ARequiredInf: TSimpleInterface);
    procedure CallsSimpleInterfaceMethod;
  end;

  TMockObjectTests = class
  published
    procedure Simple_Interface_Mock;
  end;

implementation

uses
  Rtti;

{ TMockObjectTests }

procedure TMockObjectTests.Simple_Interface_Mock;
var
  mock : TMock<TSimpleInterface>;
  sutObject : TSystemUnderTestInf;
begin
  //SETUP: Create a mock of the interface that is required by our system under test object.
  mock := TMock<TSimpleInterface>.Create;

  //SETUP: Add a check that SimpleMethod is called atleast once.
  mock.Setup.Expect.AtLeastOnce.When.SimpleMethod;

  //SETUP: Create the system under test object passing an instance of the mock interface it requires.
  sutObject := TSystemUnderTest.Create(mock.Instance);

  //TEST: Call CallsSimpleInterfaceMethod on the system under test.
  sutObject.CallsSimpleInterfaceMethod;

  //VERIFY: That our passed in interface was called at least once when CallsSimpleInterfaceMethod was called.
  mock.Verify('CallsSimpleInterfaceMethod should call SimpleMethod');
end;

{ TSystemUnderTest }

procedure TSystemUnderTest.CallsSimpleInterfaceMethod;
begin
  FInternalInf.SimpleMethod;
end;

constructor TSystemUnderTest.Create(const ARequiredInf: TSimpleInterface);
begin
  FInternalInf := ARequiredInf;
end;

end.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].