Reputation: 580
Ran into a strange issue with Azure Dev ops. I am trying to build my project in Azure Dev ops.
.Net Project structure looks like this in VS:
Solution
--src
--Test
----Test Proj. 1
----Test Proj. 2
And my azure-pipeline.yml looks like this:
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
BuildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.1.x'
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: 'restore'
projects: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'nuget.config'
- task: VSBuild@1
inputs:
solution: 'Project.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArchitecture: x64
- task: VSTest@2
displayName: Test
inputs:
testAssemblyVer2: |
**\*.UnitTest.dll
!**\obj\**
vsTestVersion: latest
runSettingsFile: test\test.runsettings
codeCoverageEnabled: true
platform: $(BuildPlatform)
configuration: $(BuildConfiguration)
diagnosticsEnabled: true
runInParallel: true
It is not able to find any test cases to run, and completes the step without running any test.
Is there something that I am missing here? or do I have to specify something else in the config?
My Test project.csproj file contains this:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="18.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
</ItemGroup>
Upvotes: 1
Views: 3812
Reputation: 89
For those seeing this thread whose problem is not due to the path being incorect: Check you have an appropriate test adapter for the framework you're using. In the above case it was MSTest
so MSTest.TestAdapter
nuget package would need to be installed in each test project
Upvotes: 3
Reputation: 76928
Azure devops not running MS test unit tests
According to your settings for Test files is:
**\*.UnitTest.dll
!**\obj\**
You should make sure that the name of your test project ends with .UnitTest
, like Test.UnitTest
, otherwise, the generate dll file should not be *.UnitTest.dll
.
To resolve this issue, you could use test
as a matching keyword(Make sure your test project name contains the test
keyword):
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
If above not help you, please try to share your test project name and the log of your test task.
Upvotes: 2