API_MockTestHelper
Class · Group: Web Services
apex
global inherited sharing class API_MockTestHelperTest helper for API mock verification. Provides assertion methods that delegate to API_MockFactory verification API with descriptive error messages.
Example
apex
API_MockFactory.forService('API_SendEmail').body('{}').statusCode(200).register();
// ... execute callout logic ...
API_MockTestHelper.assertServiceCalled('API_SendEmail');
API_MockTestHelper.assertServiceCalledTimes('API_SendEmail', 1);See Also: API_MockFactory
Methods
| Method | Description |
|---|---|
| global static void assertLastRequestContains(String serviceName, String expectedContent) | Asserts that the last request body contains the expected text. |
| global static void assertServiceCalled(String serviceName) | Asserts that a service was called at least once. |
| global static void assertServiceCalledTimes(String serviceName, Integer expectedCount) | Asserts that a service was called exactly the specified number of times. |
| global static void assertServiceNeverCalled(String serviceName) | Asserts that a service was never called. |
assertLastRequestContains
apex
global static void assertLastRequestContains(String serviceName, String expectedContent)Asserts that the last request body contains the expected text.
Parameters
| Parameter | Type | Description |
|---|---|---|
serviceName | String | The service class name to verify |
expectedContent | String | Text expected in the last request body |
assertServiceCalled
apex
global static void assertServiceCalled(String serviceName)Asserts that a service was called at least once.
Parameters
| Parameter | Type | Description |
|---|---|---|
serviceName | String | The service class name to verify |
assertServiceCalledTimes
apex
global static void assertServiceCalledTimes(String serviceName, Integer expectedCount)Asserts that a service was called exactly the specified number of times.
Parameters
| Parameter | Type | Description |
|---|---|---|
serviceName | String | The service class name to verify |
expectedCount | Integer | The expected number of invocations |
assertServiceNeverCalled
apex
global static void assertServiceNeverCalled(String serviceName)Asserts that a service was never called.
Parameters
| Parameter | Type | Description |
|---|---|---|
serviceName | String | The service class name to verify |