This post is part of the New Functionality In Microsoft Dynamics 365 Business Central 2025 Wave 1 series in which I am taking a look at the new functionality introduced in Microsoft Dynamics 365 Business Central 2025 Wave 1.
The 3rd of the new functionality in the Development section is mock outbound HttpClient web service calls during testing.
To allow for easier testability of AL code that includes outbound web service calls, Microsoft are introducing the ability to mock such calls. This allows the developer to hardcode return values to the calling code during tests, without actually performing the outbound web service call. The ability to mock calls is especially valuable when testing Copilot and AI features, as developers can write unit tests for these without actually connecting to Azure OpenAI Service, and thereby save any unnecessary token consumption.
Enabled for: Admins, makers, marketers, or analysts, automatically
Public Preview: Apr 2025
General Availability: Apr 2025
Feature Details
AL developers will be able to easily mock out HttpClient Get/Put/Delete/Post calls in unit tests. The idea is to allow easy substitutions of the responses of HttpClient calls in unit tests by introducing a new handler function to intercept HttpClient calls.
The signature is expected to be:
[HttpClientHandler]
procedure MyHandler(path: Text/Uri; requestType: HttpRequestType; var response: TestHttpResponseMessage; var success: Boolean): boolean
The default behavior will be to prevent making an actual request, but there should be the option to do so by changing the exit value.