Skip to content

Instantly share code, notes, and snippets.

View tet3's full-sized avatar

Thomas Taylor tet3

  • Philadelphia, PA
  • X @tet3
View GitHub Profile
@tet3
tet3 / HttpMockRegistry.cls
Created July 29, 2022 18:03 — forked from SpenceDiNicolantonio/HttpMockRegistry.cls
[More Robust Mocking in Apex] A dynamic HTTP mock registry and a configurable Stub class to simplify and enhance mocking for Apex unit tests #salesforce #apex
/**
* A registry built around the Salesforce Mocking API that allows declarative mocking of HTTP callouts. Mocks responses
* can be registered either for a specific endpoint and path or for all paths on an endpoint, with the former taking
* precedence.
*/
@IsTest
public class HttpMockRegistry {
// Default mock response for HTTP requests
public static final HttpResponse DEFAULT_MOCK_RESPONSE = createSuccessResponse('Default mock response');