- Print
- Comment
- DarkLight
- PDF
Local Unit Tests in DevOps Pipeline
In the below video we will take a look at how to run the local unit tests which would test the workflows when they are deployed to the function runtime on the build agent. These will be ran as part of the devops pipeline.
The pipeline is at the below location:
https://github.com/michaelstephensonuk/IntegrationPlaybook-LogicApp-Standard-Testing-Example/blob/main/.pipelines/build_and_deploy_dev.yml
The snippets from the pipeline to run the tests are below. Note I chose to run the tests with the dotnet test command myself so I could control the logger a bit more than the out of the box task because I felt I could get more useful output in the devops console window. I would also sometimes get issues with flaky tests from the out of the box task which I dont get running the command directly.
- powershell: |
dotnet test --logger:"trx;LogFileName=$(System.DefaultWorkingDirectory)/$(RepoFolder)/logicapp.testing.unittests\TestResults.xml" --logger:"console;verbosity=normal"
workingDirectory: '$(System.DefaultWorkingDirectory)/$(RepoFolder)/logicapp.testing.unittests'
displayName: 'Execute Unit Tests'
enabled: true
continueOnError: true
To publish the test results to devops we use
- task: PublishTestResults@2
displayName: 'Publish Test Results TestResults.xml'
enabled: true
continueOnError: true
inputs:
testResultsFormat: VSTest
testResultsFiles: TestResults.xml
searchFolder: '$(System.DefaultWorkingDirectory)/$(RepoFolder)/logicapp.testing.unittests'
failTaskOnFailedTests: true
testRunTitle: '$(BUILD.DEFINITIONNAME) Unit Tests'