Skip to content

Unit testing framework for Azure Logic Apps (Standard)

License

Notifications You must be signed in to change notification settings

LogicAppUnit/TestingFramework

Repository files navigation

LogicAppUnit Testing Framework

LogicAppUnit is a testing framework that simplifies the creation of automated unit tests for Standard Logic Apps running in a local development environment, or in a build server as part of a DevOps pipeline. Standard Logic Apps do not include an out-of-the-box testing capability and this framework has been designed to fill this gap. The framework is based on the Logic Apps Sample Test Framework that was developed by Henry Liu, and includes additional functionality to make it easier to author and run tests and validate (assert) the results.

The framework does not support the testing of:

  • Consumption Logic App workflows.
  • Standard Logic App workflows that have been deployed to Azure.

The testing framework has been designed to make it easier to perform isolated unit testing of a workflow. The framework does this by modifying a copy of the workflow definition to remove the dependencies on external services and APIs, without affecting the functionality or behaviour of the workflow. This means that workflows can be easily tested in a developer's local environment, and by a DevOps pipeline running on a build server, where there is no access to Azure services or any other workflow dependencies.

Key Features

  • Replace non-HTTP triggers with HTTP triggers to enable automated testing of every workflow, irrespective of the trigger type.
  • Remove external service dependencies for built-in service provider connectors by replacing these actions with HTTP actions and a mock HTTP server that is managed by the framework.
  • Remove external service dependencies for managed API connectors by automatically re-configuring managed API connections to use a mock HTTP server that is managed by the framework.
  • Remove dependencies on invoked workflows and called local functions by replacing the Invoke Workflow and Call Local Function actions with HTTP actions and a mock HTTP server that is managed by the framework.
  • Remove all retry policies to ensure that tests exercising failure scenarios do not take a long time to execute.
  • A fluent API to configure request matching and the creation of responses for the mock HTTP server.
  • Detailed test execution logging to help with workflow test authoring and debugging.
  • Programmatic access to the workflow run history to enable assertion of workflow run status, response status, action status, input and output messages and more. This includes support for action repetitions inside a loop.
  • Programmatic access to the requests sent to the mock HTTP server to enable assertion of the data sent from the workflow to external services and APIs.
  • Override specific local settings for a test case to enable more testing scenarios (e.g. feature flags).

Projects

This code repository includes four projects:

Name Description
LogicAppUnit The testing framework.
LogicAppUnit.Samples.LogicApps.Tests Test project that demonstrates the features of the testing framework.
LogicAppUnit.Samples.LogicApps Workflows that are tested by the sample test project.
LogicAppUnit.Samples.Functions Local .NET Framework functions that are called by workflows.

Packages

Download the LogicAppUnit testing framework package from nuget: https://www.nuget.org/packages/LogicAppUnit/

NuGet Version Badge NuGet Download Badge

Compatibility

The framework has been tested with these environments:

  • Windows
  • Linux (Ubuntu)
  • MacOS

Give a Star ⭐

If you like or are using this project please give it a star. Thanks.

Main Contributors

Documentation

The best way to understand how the framework works and how to write tests using it is to read the wiki and look at the example tests in the LogicAppUnit.Samples.LogicApps.Tests project.

Future Improvements and Changes

This is a list of possible future improvements and changes for the framework. Please create a new issue if there are other features that you would like to see.

  • Add more features to the fluent API for request matching and the creation of mock responses.
  • Add a Verifiable() feature to the fluent API so that a test case can assert that a test execution did send a request to the mock HTTP server that was successfully matched. This would work in a simialar way to the Verifiable() feature in the moq unit testing framework.
  • Auto-generate C# test cases based on a workflow's run history in the local development environment.