This is an extension to make it easier to develop with Apex mocks by providing useful code snippets.
https://github.com/apex-enterprise-patterns/fflib-apex-mocks
Where there are blanks - the snippet will default the cursor to populate the blank. If there are multiple blanks, after populating the first one, pressing tab will take the cursor to the next slot.
APEX_MOCKS is provided as a default name for the Mock Builder but will be highlighted by default and will be overridable immediately.
@IsTest(isParallel=true)
class Filename {
@IsTest
public static void methodUnderTest_changes_expectedResult() {
Test.startTest();
Test.stopTest();
}
}
@isTest
public static void methodUnderTest_changes_expectedResult() {
Test.startTest();
Test.stopTest();
}
private with sharing class Answer implements fflib_Answer {
public Answer() {}
public Object answer(fflib_InvocationOnMock invocation) {
ArgumentType argumentOne = (ArgumentType) invocation.getArgument(0);
return null;
}
}
Assert.areEqual(, , );
Assert.isInstanceOfType(, .class, );
Assert.isNull(, );
Assert.isTrue(, );
fflib_System.assertEquals(fflib_Match.(), ,);
APEX_MOCKS.startStubbing();
APEX_MOCKS.stopStubbing();
Test.startTest();
Test.stopTest();
fflib_ApexMocks APEX_MOCKS = new fflib_ApexMocks();
fflib_ArgumentCaptor serviceParmsCaptor = fflib_ArgumentCaptor.forClass(
.class
);
(Type) .capture()
((Service) APEX_MOCKS.verify(serviceToMock, 1)).methodName((ArgumentType) fflib_Match.anyObject());
mockService = () APEX_MOCKS.mock(.class)
((ServiceType) APEX_MOCKS.doThrowWhen(
new TestException('Splat!'),
mockService
))
.methodName((ArgumentType) fflib_Match.anyObject());
APEX_MOCKS.when(
mockService.methodName((ArgumentType) fflib_Match.anyObject())
)
.thenReturn(mockResult);
APEX_MOCKS.when(
mockService.methodName((ArgumentType) fflib_Match.anyObject())
)
.thenAnswer(answerInstance);
System.runAs() {
}