在Azure DevOps管道中运行NUnit测试 [英] Run NUnit tests in Azure DevOps pipeline

查看:18
本文介绍了在Azure DevOps管道中运行NUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能吗?(似乎没有。它不支持NUnit吗?我应该改用什么?)

这是我的测试项目。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
    <PackageReference Include="NUnit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..TheProjectToBeTestedTheProjectToBeTested.csproj" />
  </ItemGroup>

</Project>

这是我的azure-pipelines.yml

pool: 'TFSBuild'

variables:
# The web app will not build because it is netcore3.1 and the server only supports netcore3.0.
  solution: '**/*Build.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    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)'

# I added this and I don't undertand it.
- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
     **$(BuildConfiguration)*test*.dll
     **$(BuildConfiguration)***test*.dll
     !***Microsoft.VisualStudio.TestPlatform*
     !**obj**
    searchFolder: '$(System.DefaultWorkingDirectory)'

但是,测试不会运行。

##[section]Starting: VSTest
==============================================================================
Task         : Visual Studio Test
Description  : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
Version      : 2.153.9
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/test/vstest
==============================================================================
SystemVssConnection exists true
SystemVssConnection exists true
SystemVssConnection exists true
Running tests using vstest.console.exe runner.
======================================================
Test selector : Test assemblies
Test filter criteria : null
Search folder : E:TFS8s
VisualStudio version selected for test execution : latest
Attempting to find vstest.console from a visual studio installation.
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : false
SystemVssConnection exists true
Run the tests locally using vstest.console.exe
========================================================
Test selector : Test assemblies
Test assemblies : **Release*test*.dll,**Release***test*.dll,!***Microsoft.VisualStudio.TestPlatform*,!**obj**
Test filter criteria : null
Search folder : E:TFS8s
Run settings file : E:TFS8s
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : false
Rerun failed tests: false
VisualStudio version selected for test execution : latest
Attempting to find vstest.console from a visual studio installation.
========================================================
======================================================
[command]"E:Program Files (x86)Microsoft Visual Studio2019ProfessionalCommon7IDEExtensionsTestPlatformvstest.console.exe" @E:TFS\_temp126341f1-33c9-11eb-a545-b3a68600e11b.txt
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-preview-20190715-02
Copyright (c) Microsoft Corporation.  All rights reserved.

vstest.console.exe 
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0TheProjectToBeTested.Test.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.CommunicationUtilities.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.CoreUtilities.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.CrossPlatEngine.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.PlatformAbstractions.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.Utilities.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0NUnit3.TestAdapter.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0csMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0csMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0csMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0deMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0deMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0deMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0esMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0esMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0esMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0frMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0frMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0frMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0itMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0itMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0itMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0jaMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0jaMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0jaMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0koMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0koMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0koMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0plMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0plMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0plMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0pt-BRMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0pt-BRMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0pt-BRMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0
uMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0
uMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0
uMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	esthost.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	rMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	rMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	rMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HansMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HansMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HansMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HantMicrosoft.TestPlatform.CommunicationUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HantMicrosoft.TestPlatform.CoreUtilities.resources.dll"
"E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HantMicrosoft.TestPlatform.CrossPlatEngine.resources.dll"
/logger:"trx"
/TestAdapterPath:"E:TFS8s"
Starting test execution, please wait...
Test run will use DLL(s) built for framework .NETFramework,Version=v4.0 and platform X86. Following DLL(s) do not match framework/platform settings.
TheProjectToBeTested.Test.dll is built for Framework .NETCoreApp,Version=v3.0 and Platform AnyCPU.
Microsoft.TestPlatform.CommunicationUtilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.TestPlatform.CoreUtilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.TestPlatform.CrossPlatEngine.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.TestPlatform.PlatformAbstractions.dll is built for Framework .NETCoreApp,Version=v2.1 and Platform AnyCPU.
Microsoft.TestPlatform.Utilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
NUnit3.TestAdapter.dll is built for Framework .NETCoreApp,Version=v2.1 and Platform AnyCPU.
testhost.dll is built for Framework .NETCoreApp,Version=v2.1 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

No test is available in E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0TheProjectToBeTested.Test.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.CommunicationUtilities.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.CoreUtilities.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.CrossPlatEngine.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.PlatformAbstractions.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0Microsoft.TestPlatform.Utilities.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0NUnit3.TestAdapter.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0csMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0csMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0csMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0deMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0deMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0deMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0esMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0esMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0esMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0frMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0frMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0frMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0itMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0itMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0itMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0jaMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0jaMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0jaMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0koMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0koMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0koMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0plMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0plMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0plMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0pt-BRMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0pt-BRMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0pt-BRMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0
uMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0
uMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0
uMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	esthost.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	rMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	rMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0	rMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HansMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HansMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HansMicrosoft.TestPlatform.CrossPlatEngine.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HantMicrosoft.TestPlatform.CommunicationUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HantMicrosoft.TestPlatform.CoreUtilities.resources.dll E:TFS8sTheProjectToBeTested.TestinRelease
etcoreapp3.0zh-HantMicrosoft.TestPlatform.CrossPlatEngine.resources.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Results File: E:TFS8sTestResultsTFSBUILD$_TFSBUILD_2020-12-01_11_33_48.trx

No Result Found to Publish 'E:TFS8sTestResultsTFSBUILD$_TFSBUILD_2020-12-01_11_33_48.trx'.
##[section]Async Command Start: Publish test results
##[section]Async Command End: Publish test results
##[section]Finishing: VSTest

推荐答案

请移动到dotnet command and instead of using VSTest run it using this

如果您的存储库中有测试项目,则使用.NET Core任务通过MSTest、xUnit和NUnit等测试框架运行单元测试。

steps:
# ...
# do this after other tasks such as building
- task: DotNetCoreCLI@2
  inputs:
    command: test
    projects: '**/*Tests/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

这篇关于在Azure DevOps管道中运行NUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆