c# - Azure Pipeline VSTest@2 Task 认为以“Tester”结尾的项目是测试项目
问题描述
我的 YAML:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- 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)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
我有一个名为DatabaseModeler Tester
:
当管道运行时,我收到以下错误:
这个项目不是一个测试项目,也没有任何测试依赖。
解决方案
VsTest 任务的默认值为:
{
"name": "testAssemblyVer2",
"type": "multiLine",
"label": "Test files",
"defaultValue": "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**",
"required": true,
"helpMarkDown": "Run tests from the specified files.<br>Ordered tests and webtests can be run by specifying the .orderedtest and .webtest files respectively. To run .webtest, Visual Studio 2017 Update 4 or higher is needed. <br><br>The file paths are relative to the search folder. Supports multiple lines of minimatch patterns. [More information](https://aka.ms/minimatchexamples)",
"groupName": "testSelection",
"properties": {
"rows": "3",
"resizable": "true"
},
"visibleRule": "testSelector = testAssemblies"
},
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/VsTestV2/task.json#L72
请注意,该任务将拾取名称中包含“test”的任何程序集。
"defaultValue": "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**",
在 VsTest2 任务上设置testAssemblyVer2
属性将允许您选择正确的测试程序集。
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
testAssemblyVer2: "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**\n!**\Tester*.dll",
Tester*.dll
在这种情况下,我为:添加了一个特定的排除\n!**\Tester*.dll
项,但您也可以创建一个更具体的规则来根据您的解决方案的文件夹结构选择您的测试程序集,例如当您的测试都位于tests
文件夹中时:
"**\\tests\\*test*.dll"
推荐阅读
- dnsjava - 如何禁用DNS java的递归查询?
- android - 如何在 Cordova 中获取系统的文件名?
- java - 如何在 maven 3 中获取最新的 RELEASE 版本的依赖项?
- json - 如何将 retryPolicy 设置为 ARM 模板变量
- python - Python - 忽略列表中的字符串不起作用
- spring-cloud-stream - 使用 zipkin + kafka 时 Spring 云流消息的 Sleuth 检测丢失
- c# - C#如何显示货币增加减少?
- .net - 身份服务器:在 MVC 客户端中使用混合流向 ClaimPrincipal 添加声明
- ruby-on-rails - Rails 将多个对象合并为一个数组
- c++ - 如何在qt中所有继承类的基类中使用信号?