mock
Mock objects for unit testing. Track method calls, stub return values and verify call counts with Verify().
Install
ppm install mock
Usage Example
uses mock, testing;
var m := Create('EmailService');
WhenCalled(m, 'Send', 'ok');
// Exercise the mock
Called(m, 'Send', ['alice@example.com', 'Hello!']);
// Assertions
BeginSuite('Email Tests');
It('should call Send exactly once', procedure begin
Verify(m, 'Send', 1); // passes if called exactly once
Expect(WasCalled(m, 'Send'), 'Send was called');
ExpectEqual(IntToStr(CallCount(m, 'Send')), '1', 'count');
end);
Summary;
Features
Method call tracking per mock
Return value stubbing with WhenCalled()
Call count verification with Verify()
WasCalled() boolean check
Argument recording for all calls