I have been really getting frustrated with getting unit tests to run in a Azure Devops Pipeline below is my YAML file contents
trigger:
- main
pool:
vmImage: 'windows-2019'
variables:
solution: '**/FestWise.stock*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
imageRepository: 'festwisestock'
dotNetCoreVrs: '3.1.x'
steps:
- task: UseDotNet@2
inputs:
version: '$(dotNetCoreVrs)'
packageType: 'sdk'
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/FestWise.stock*.sln'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: 'Restore project dependencies'
inputs:
command: 'restore'
projects: '**/FestWise.Stock/FestWise.Stock.API/FestWise.StockService*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build the project - $(buildConfiguration)'
inputs:
command: 'build'
arguments: '--no-restore --configuration $(buildConfiguration)'
projects: '**/FestWise.Stock/FestWise.Stock.API/FestWise.StockService*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Run unit tests - $(buildConfiguration)'
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration)'
publishTestResults: true
projects: '**/*StockService.UnitTests.csproj'
the result is as follows:
Starting: Run unit tests - Release
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.187.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
C:\hostedtoolcache\windows\dotnet\dotnet.exe test D:\a\1\s\FestWise.Stock\FestWise.StockService.UnitTests\FestWise.StockService.UnitTests.csproj --logger trx --results-directory D:\a\_temp --no-build --configuration Release
##[warning]No test result files were found.
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
Finishing: Run unit tests - Release
This is the furthest that i have come, it states it found the correct project but subsequently doesnt run any tests