简体   繁体   English

Azure devops 未运行 MS 测试单元测试

[英]Azure devops not running MS test unit tests

Ran into a strange issue with Azure Dev ops. Azure Dev ops 遇到了一个奇怪的问题。 I am trying to build my project in Azure Dev ops.我正在尝试在 Azure Dev ops 中构建我的项目。

.Net Project structure looks like this in VS: .Net 项目结构在 VS 中如下所示:

Solution
--src
--Test
----Test Proj. 1
----Test Proj. 2

And my azure-pipeline.yml looks like this:我的 azure-pipeline.yml 看起来像这样:

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:我的测试 project.csproj 文件包含以下内容:

  <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>

Azure devops not running MS test unit tests Azure devops 未运行 MS 测试单元测试

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 .您应该确保测试项目的名称以.UnitTest ,例如Test.UnitTest ,否则生成的 dll 文件不应为*.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作为匹配关键字(确保您的测试项目名称包含test关键字):

**\*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.如果以上对您没有帮助,请尝试分享您的测试项目名称和测试任务的日志。

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在上述情况下,它是MSTest ,因此需要在每个测试项目中安装MSTest.TestAdapter nuget package

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure DevOps 中运行 Azure Function v1 单元测试 - Running Azure Function v1 unit tests in Azure DevOps 在 Azure DevOps 上运行 Playwright dotnet 测试 - Running Playwright dotnet tests on Azure DevOps "在一个单元测试项目中运行多个单元测试" - Running multiple Unit Tests in an unit test project Visual Studio 15.8.1 未运行 MS 单元测试 - Visual Studio 15.8.1 not running MS unit tests Azure Devops - MSTest - 如果我的单元测试失败,我如何使构建失败,但在集成测试失败时继续(带有警告/通知) - Azure Devops - MSTest - How can I fail a build if my unit tests fail, but continue (with warning/notification) when integration test fail C# 单元测试在 Azure DevOps 中运行,但不在 Visual Studio 中运行 - C# Unit Tests run in Azure DevOps but not in Visual Studio 运行用 C#(MS 测试)编写的功能测试作为性能测试 - Running functional tests written in C#(MS test) as a perf test .Net/VS 测试运行器在 Azure DevOps 中运行时失败 - .Net/VS Test runner fails when running in Azure DevOps 定时器触发单元测试 Azure Function:提供测试数据 - Unit Tests for timer triggered Azure Function: provide test data 运行单元测试时测试类的范围是什么? - What is the scope of a test class when running unit tests?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM