Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 1.69 KB

File metadata and controls

59 lines (44 loc) · 1.69 KB

AzureFunctions.TestFramework.Warmup

NuGet

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.

Usage

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();
    }
}

API

Task<FunctionInvocationResult> InvokeWarmupAsync(
    this IFunctionsTestHost host,
    string functionName,
    WarmupContext? context = null,
    CancellationToken cancellationToken = default)
  • functionName — the name of the warmup function (case-insensitive).
  • context — optional WarmupContext passed to the function.

References

License

MIT