WarmupTrigger invocation support for the Azure Functions Test Framework. Provides InvokeWarmupAsync(...) — an extension on IFunctionsTestHost that lets you trigger warmup functions directly from integration tests.
using AzureFunctions.TestFramework.Core;
using AzureFunctions.TestFramework.Warmup;
public class WarmupFunctionTests : IAsyncLifetime
{
private IFunctionsTestHost _testHost;
public async Task InitializeAsync()
{
_testHost = await new FunctionsTestHostBuilder()
.WithFunctionsAssembly(typeof(MyWarmupFunction).Assembly)
.BuildAndStartAsync();
}
[Fact]
public async Task WarmupTrigger_RunsSuccessfully()
{
var result = await _testHost.InvokeWarmupAsync("WarmupTrigger");
Assert.True(result.Success);
}
public async Task DisposeAsync()
{
await _testHost.StopAsync();
_testHost.Dispose();
}
}Task<FunctionInvocationResult> InvokeWarmupAsync(
this IFunctionsTestHost host,
string functionName,
WarmupContext? context = null,
CancellationToken cancellationToken = default)functionName— the name of the warmup function (case-insensitive).context— optionalWarmupContextpassed to the function.
MIT