A comprehensive testing framework for Azure Functions that integrates with ReqnRoll (formerly SpecFlow) to enable behaviour-driven development (BDD) testing of Azure Functions projects.
This repository contains the Azure Functions libraries originally published at the deprecated Corvus.Testing repo. The readme of that repository has been updated with an explaination and the list of new packages.
This project builds upon the Corvus.Testing.ReqnRoll repository but we've split the core testing framework from platform integrations (i.e. Azure Functions) because these evolve at different rates and have different levels of stability.
- ✅ Programmatically start and stop Azure Functions instances for testing
- ✅ Support for both In-Process and Isolated Azure Functions models
- ✅ ReqnRoll integration with step definitions and hooks
- ✅ Port management and conflict resolution for parallel test execution
- ✅ Environment variable configuration for test scenarios
- ✅ Process output capture and logging for debugging
- ✅ Graceful shutdown with fallback force termination
- ✅ Cross-platform support (Windows, macOS, Linux)
# Core functionality
dotnet add package Corvus.Testing.AzureFunctions
# ReqnRoll integration
dotnet add package Corvus.Testing.AzureFunctions.ReqnRoll
using Microsoft.Extensions.Logging;
using Corvus.Testing.AzureFunctions;
// Create a logger
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
var logger = loggerFactory.CreateLogger<FunctionsController>();
// Create and start a functions instance
var controller = new FunctionsController(logger);
await controller.StartFunctionsInstanceAsync(
path: "MyFunctionApp", // Function project path
port: 7071, // Port to run on
runtime: "net8.0" // Runtime version
);
// Your tests here...
using var client = new HttpClient();
var response = await client.GetAsync("http://localhost:7071/api/MyFunction");
// Cleanup
await controller.TeardownFunctionsAsync();
@functionsTest
Feature: My Azure Function
As a developer
I want to test my Azure Function
So that I can ensure it works correctly
Scenario: Function returns expected response
Given I start a functions instance for the local project 'MyFunctionApp' on port 7071
When I send a GET request to 'http://localhost:7071/api/MyFunction?name=World'
Then I receive a 200 response code
And the response body contains the text 'Hello, World!'
For comprehensive documentation, examples, and best practices, see:
The documentation covers:
- 🏗️ Architecture and Core Components
- 🎯 Usage Patterns (per-test, per-feature, multiple apps)
- ⚙️ Configuration Management
- 📝 Detailed Examples with both unit tests and ReqnRoll scenarios
- 🔧 Best Practices for performance and reliability
- 🐛 Troubleshooting Guide for common issues
Test your Azure Functions in realistic environments with external dependencies like databases, service bus, and APIs.
Write human-readable specifications that automatically test your functions using Gherkin syntax.
Test multiple Azure Function apps simultaneously to validate complex distributed scenarios.
Automate function testing in build pipelines with reliable startup, execution, and teardown.
- .NET 8.0 or later
- Azure Functions Core Tools v4
- Visual Studio 2022 or VS Code with C# extension
We welcome contributions! Please see our contributing guidelines for details on:
- Code style and conventions
- Testing requirements
- Documentation standards
- Pull request process
This project is licensed under the Apache 2.0 License.
This project is maintained by endjin and builds upon the excellent work of the Azure Functions and ReqnRoll communities.
For questions, issues, or feature requests, please open an issue on GitHub.