Closed AllanOricil closed 1 year ago
@AllanOricil
Skip specifying the mocks.when(...)
statement. Simply do the verify. As in ...
fflib_ApexMocks mocks = new fflib_ApexMocks();
IMyService mockMyService = (IMyService) mocks.mock(IMyService.class);
// Execute the test implementing the void method
((IMyService) mocks.verify(mockMyService, 1))
.doSomethingUseful(
fflib_Match.sObjectWith(
new Map<SObjectField, Object> {
Contact.Id =>expectedId,
Contact.Nickname__c => expectedNickname,
Contact.LastSynchronized__c => expectedSyncedOn
}));
The "Matching" logic is optional but illustrates if needed.
@stohn777 cool. I will try that :D
I have service classes which are used on OnBefore events that don't return anything. They literally just pass info to a Domain,which also does not return anything, to update my record data. I wanted to mock this service method and I couldn't because it is always expecting a "thenReturn()". I would like to mock this method because I want to use verify to check it has been called.