Skip to content

corvus-dotnet/Corvus.Testing.AzureFunctions.ReqnRoll

Repository files navigation

Corvus.Testing.AzureFunctions.ReqnRoll

Build Status GitHub license

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.

🚀 Features

  • 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)

📦 Packages

Package Description NuGet
Corvus.Testing.AzureFunctions Core functionality for managing Azure Functions instances NuGet
Corvus.Testing.AzureFunctions.ReqnRoll ReqnRoll integration for BDD testing NuGet
Corvus.Testing.AzureFunctions.ReqnRoll.NUnit A metapackage that encapsulates the required dependencies when using Corvus.Testing.AzureFunctions.ReqnRoll NuGet

🏃 Quick Start

Installation

# Core functionality
dotnet add package Corvus.Testing.AzureFunctions

# ReqnRoll integration
dotnet add package Corvus.Testing.AzureFunctions.ReqnRoll

Basic Usage

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

ReqnRoll Integration

@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!'

📚 Documentation

For comprehensive documentation, examples, and best practices, see:

📖 Complete Documentation

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

🎯 Use Cases

Integration Testing

Test your Azure Functions in realistic environments with external dependencies like databases, service bus, and APIs.

BDD Testing with ReqnRoll

Write human-readable specifications that automatically test your functions using Gherkin syntax.

Microservices Testing

Test multiple Azure Function apps simultaneously to validate complex distributed scenarios.

CI/CD Pipeline Testing

Automate function testing in build pipelines with reliable startup, execution, and teardown.

🔧 Requirements

  • .NET 8.0 or later
  • Azure Functions Core Tools v4
  • Visual Studio 2022 or VS Code with C# extension

🤝 Contributing

We welcome contributions! Please see our contributing guidelines for details on:

  • Code style and conventions
  • Testing requirements
  • Documentation standards
  • Pull request process

📄 License

This project is licensed under the Apache 2.0 License.

🙏 Acknowledgments

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.

OpenChain

About

A comprehensive BDD based integration testing framework for Azure Functions (In Process and Isolated).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •