简体   繁体   English

Azure管道未运行NUnit测试

[英]Azure pipeline not running NUnit tests

Just been introduced to Azure piplelines. 刚刚被介绍给Azure piplelines。 My project is a .NET project and is linked up with Azure but does not run my Unit Tests before integrating (therefore is integrating everything even with failing tests) 我的项目是一个.NET项目,并且与Azure链接在一起,但是在集成之前不运行我的单元测试(因此即使失败的测试也要集成所有内容)

My .yaml file is: 我的.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)'

My unit tests are in the solution under a project called MyProjectTests and in a file called ProjectTests.cs . 我的单元测试在解决方案下的MyProjectTests项目和ProjectTests.cs文件中。 Can anyone please advise what I need to add to my yaml file (or do in general?) to get these to run please? 谁能告诉我我需要添加到yaml文件中的内容(或一般情况下执行该操作),以便使其运行? I have looked into this myself and can't seem to find a solution and I want to avoid clogging up my commit history with failed attempts to run the unit tests. 我本人对此进行了调查,似乎无法找到解决方案,并且我想避免因尝试运行单元测试而失败的提交历史记录被阻塞。

Thanks so much. 非常感谢。

UPDATE: 更新:

I have fixed by adding the following: 我通过添加以下内容进行了修复:

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

Here you go. 干得好。

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

You can choose whatever configuration you like, of course. 当然,您可以选择所需的任何配置。 And the displayName is optional. 并且displayName是可选的。 If any of your tests fail, the Pipeline will abort subsequent steps. 如果您的任何测试失败,则管道将中止后续步骤。

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

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