-
Notifications
You must be signed in to change notification settings - Fork 14
Automated Testing using a DevOps Pipeline
Mark Abrams edited this page Jun 30, 2023
·
7 revisions
Unit tests written using LogicAppUnit can be run as part of a DevOps pipeline, just like any other tests that you might write for C# or other languages. The easiest way to run tests is to use the dotnet test
command.
The following sections show example pipeline definitins for GitHub Actions and Azure DevOps pipelines.
The LogicAppUnit testing framework in GitHub includes an action that builds the code and runs a set of unit tests. The action YAML file is stored in the code repo: .github/workflows/build.yml
.
The key parts of the YAML file are shown below.
- Install the .NET 6.0 SDK:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- Restore NuGet dependencies and build the solution:
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- Install and configure the Logic Apps runtime environment, this includes the Azure Functions Core tools, node and Azurite:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Functions Core tools
run: 'npm install -g azure-functions-core-tools@4 --unsafe-perm true'
- name: Install Azurite
run: 'npm install -g azurite@3.24.0'
- name: Start Azurite services in the background
run: 'azurite &'
shell: bash
- And finally, run the tests:
- name: Run tests
run: dotnet test --no-restore --verbosity normal --logger "trx"
The key parts of the DevOps pipeline YAML file are shown below. Note that this YAML file targets a Windows build agent.
- Install the .NET 6.0 SDK:
- task: UseDotNet@2
displayName: 'Setup .Net'
inputs:
packageType: sdk
version: '6.x'
installationPath: $(Agent.ToolsDirectory)/dotnet
- Restore NuGet dependencies and build the solution:
- task: DotNetCoreCLI@2
displayName: 'Restore dependencies'
inputs:
command: restore
verbosityRestore: Normal
projects: '$(System.DefaultWorkingDirectory)/**/*.Tests.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: build
arguments: '--no-restore'
projects: '$(System.DefaultWorkingDirectory)/**/*.Tests.csproj'
- Install and configure the Logic Apps runtime environment, this includes the Azure Functions Core tools, node and Azurite:
- task: NodeTool@0
displayName: 'Install node'
inputs:
versionSpec: '18.x'
- task: Npm@1
displayName: 'Install Azure Functions core tools'
inputs:
command: 'custom'
customCommand: 'install -g azure-functions-core-tools@4 --unsafe-perm true'
- task: Npm@1
displayName: 'Install Azurite'
inputs:
command: 'custom'
customCommand: 'install -g azurite@3.24.0'
- task: CmdLine@2
displayName: 'Start Azurite services in the background'
inputs:
script: start /b azurite --silent
- And finally, run the tests:
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: test
arguments: '--no-restore'
projects: '$(System.DefaultWorkingDirectory)/**/*.Tests.csproj'
publishTestResults: true
- Home
- Using the Testing Framework
- Test Configuration
- Azurite
- Local Settings File
- Test Execution Logs
- Stateless Workflows
- Handling Workflow Dependencies
- Fluent API
- Automated testing using a DevOps pipeline
- Summary of Test Configuration Options
-
Example Mock Requests and Responses
- Call a Local Function action
- Invoke Workflow action
- Built-In Connectors:
- Service Bus
- SMTP
- Storage Account
- SQL Server