Fluent API
Write clean, readable test mocks with a chainable, intuitive interface.
A production-ready library for mocking HTTP callouts in Salesforce with a clean, fluent API
Traditional Salesforce HTTP mocking requires creating verbose mock classes for every test scenario. HTTP Mock Lib simplifies this with a fluent, chainable API:
@IsTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
global HTTPResponse respond(HTTPRequest req) {
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody('{"example":"test"}');
res.setStatusCode(200);
return res;
}
}
Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());new HttpMock()
.whenGetOn('/api/v1/authorize')
.body('{"example":"test"}')
.statusCodeOk()
.mock();HTTP Mock Lib is part of Apex Fluently, a suite of production-ready Salesforce libraries by Beyond the Cloud.
Ready to simplify your HTTP mocking? Get started →