Skip to content
Jonathan George By Jonathan George Software Engineer IV
Integration Testing Azure Functions with SpecFlow and C#, Part 5 - Using Corvus.SpecFlow.Extensions in a build pipeline

TL;DR - This series of posts shows how you can integration test Azure Functions projects using the open-source Corvus.Testing library and walks through the different ways you can use it in your SpecFlow projects to start and stop function app instances for your scenarios and features.

In the previous posts in this series, we introduced the Corvus.Testing project and showed how you can use the bindings and classes it provides to start functions apps as part of your scenarios and features. We're going to finish with some pointers on how to ensure these functions can run as part of your build pipelines.

Depending on how your build system works, it's relatively easy to ensure that tests using these methods are able to run as part of the build pipeline.

If, like us, you're using Azure DevOps with hosted agents, you'll need to add a step to your pipeline to install the Azure Functions Core Tools. For YAML build definitions, it looks like this:

- task: Npm@1
  displayName: 'Install Latest Azure Functions V3 Runtime'
    command: custom
    verbose: false
    customCommand: 'install -g azure-functions-core-tools@3 --unsafe-perm true'

Once that step has run, the test will be able to execute as it does locally. Note however that at the moment, the Corvus library only supports Windows build agents - this won't work if you've configured your pipeline to run a Linux agent.

GitHub actions is similarly straightforward. As with Azure DevOps, you'll need to make sure your pipeline is configured to use a Windows agent using runs-on: windows-latest in your pipeline YAML. Then simply add this step towards the start of your pipeline:

This approach should also work for other CI servers and their hosted build agents. If you're using a private agent you have the option of installing the tools globally, meaning your build scripts can just assume they are present - this very much depends on how you prefer to manage build agents.


For SpecFlow users, the techniques I've shown in these posts will help ensure your integration tests are more complete by ensuring that functions under test are hosted in a way that closely matches the Azure environment they will ultimately run in.

I've tried to keep the posts simple by only covering testing HTTP triggered functions, but these techniques can equally be used to test functions that use other trigger types too. In our projects we've used it to test functions with blob, queue and Event Hubs endpoints, as well as functions using Durable extensions.

As mentioned above, the Corvus.Testing project is open source and contributions are accepted. If you encounter problems with it, please feel free to raise an Issue - and if you're able, submit a pull request. And if you have any questions or feedback, just ask!

Azure Weekly is a summary of the week's top Microsoft Azure news from AI to Availability Zones. Keep on top of all the latest Azure developments!

Jonathan George

Software Engineer IV

Jonathan George

Jon is an experienced project lead and architect who has spent nearly 20 years delivering industry-leading solutions for clients across multiple industries including oil and gas, retail, financial services and healthcare. At endjin, he helps clients take advantage of the huge opportunities presented by cloud technologies to better understand and grow their businesses.