I have an azure pipeline to build and publish a c# project to a docker image. everything works just fine but today I wanted to add a unit test this pipeline.
so I added the task for it.
as follow:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.x'
- task: DotNetCoreCLI@2
displayName: 'DotNet - Restore'
inputs:
command: 'restore'
projects: $(project)
noCache: true
versioningScheme: 'off'
vstsFeed: 'feed'
- task: DotNetCoreCLI@2
displayName: "Run unit tests - $(Build.BuildNumber)"
inputs:
command: 'test'
arguments: '--no-build --configuration $(Build.BuildNumber)'
projects: 'path/to/Tests.csproj'
publishtestResults: true
- task: DotNetCoreCLI@2
name: 'DotnetPublish'
displayName: 'dotnet - Publish'
inputs:
command: 'publish'
projects: $(project)
arguments: '-o publish/projectapi -c release'
modifyOutputPath: false
zipAfterPublish: false
publishWebProjects: false
- task: Docker@2
name: 'dockerBuildAndPush'
displayName: 'docker - Build & Push'
inputs:
repository: $(imageRepository)
Dockerfile: $(dockerfilePath)
containerRegistry: ${{ variables.dockerRegistryServiceConnection }}
buildContext: ${{ variables.buildContext }}
tags: |
$(Build.BuildNumber)
latest
when I run the pipeline, on the test task, it take less than 2 second and it returns
##[warning]No test result files were found.
and if I head to the tests tab, I see the message that there are no tests to display.
Am I doing something wrong in my pipeline configuration?
thank you so much for any help
EDIT: There are some update about this. The issue was related to the fact that I didn't have a build task for the test csproj. When I implemented the task and run the pipeline. I got an error about a nuget package not found (private nuget). In my vsfeed in the devops panel, I can see that package exists, but for some reason the pipeline fails because it doesn't see that package. Did this ever happened to anyone and knows a workaround?