繁体   English   中英

Azure管道未运行NUnit测试

[英]Azure pipeline not running NUnit tests

刚刚被介绍给Azure piplelines。 我的项目是一个.NET项目,并且与Azure链接在一起,但是在集成之前不运行我的单元测试(因此即使失败的测试也要集成所有内容)

我的.yaml文件是:

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

我的单元测试在解决方案下的MyProjectTests项目和ProjectTests.cs文件中。 谁能告诉我我需要添加到yaml文件中的内容(或一般情况下执行该操作),以便使其运行? 我本人对此进行了调查,似乎无法找到解决方案,并且我想避免因尝试运行单元测试而失败的提交历史记录被阻塞。

非常感谢。

更新:

我通过添加以下内容进行了修复:

- task: DotNetCoreCLI@2
  inputs:
    command: test
    projects: '**/*Tests/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

干得好。

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: 'PathToTestProject/TestProject.csproj'
    arguments: '--configuration Debug'

当然,您可以选择所需的任何配置。 并且displayName是可选的。 如果您的任何测试失败,则管道将中止后续步骤。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM