目前,我正在尝试为我们的解决方案设置一个新的管道,但无法让Visual Studio测试在我的解决方案中找到正确的测试集。要么它选择一个不包含任何测试的DLL (这会导致任务失败),要么如果我指定了testAssemblyVer2属性,它会生成一个警告,指出它找不到任何要测试的程序集。
我们正在使用的基本任务配置:
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
searchFolder: '$(System.DefaultWorkingDirectory)'
runInParallel: true
codeCoverageEnabled: true
diagnosticsEnabled: true如果我们运行它,我们可以在输出中看到以下配置(部分):
...
Test assemblies : **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**
...
======================================================
[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" @d:\a\_temp\66884a11-77b3-11e9-b7cb-25533524cce5.txt
Microsoft (R) Test Execution Command Line Tool Version 16.0.1
Copyright (c) Microsoft Corporation. All rights reserved.
"d:\a\1\s\Tests\Api\FirstController.Tests\bin\Release\netcoreapp2.1\FirstController.Tests.dll"
"d:\a\1\s\Tests\Api\SecondController.Tests\bin\Release\netcoreapp2.1\SecondController.Tests.dll"
"d:\a\1\s\Tests\CreateTranslateStringsFromDeviceConfigurationSettings\bin\Release\netcoreapp2.1\CreateTranslateStringsFromDeviceConfigurationSettings.dll"
"d:\a\1\s\Tests\Api\FourthController.Tests\bin\Release\netcoreapp2.1\FourthController.Tests.dll"
"d:\a\1\s\Tests\Api\FifthController.Tests\bin\Release\netcoreapp2.1\FifthController.Tests.dll"
/Settings:"d:\a\_temp\69a604d0-77b3-11e9-b7cb-25533524cce5.runsettings"
/EnableCodeCoverage
/logger:"trx"
/TestAdapterPath:"d:\a\1\s"
Starting test execution, please wait...正如您所看到的,有一个程序集CreateTranslateStringsFromDeviceConfigurationSettings不包含任何测试,但被选为测试的候选。我从我的具体解决方案中获取了确切的原始名称,只是为了表明它显然与模式不匹配,但已被选中。现在我们尝试通过定义我们自己的匹配模式来避免这个问题。
如果我们通过助手创建任务,它将默认添加以下值:
testAssemblyVer2: '**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**'如果我们运行这个命令,我们会得到以下输出:
...
Test assemblies : **\*test*.dll !**\*TestAdapter.dll !**\obj\**
...
##[warning]No test assemblies found matching the pattern: **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**.在输出中,您可以看到,测试程序集列表没有逗号分隔,这在某种程度上表明该值未被正确理解,因此可能导致空列表。
因此,我们尝试从第一个运行的输出中复制并粘贴逗号,这将产生以下配置和(失败的)输出:
testAssemblyVer2: '**\*test*.dll,!**\*TestAdapter.dll,!**\obj\**'输出:
...
Test assemblies : **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**
...
##[warning]No test assemblies found matching the pattern: **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**.输出现在与第一个匹配,但它仍然不起作用。因此,使用逗号似乎不是可行的方法。
因此,在第四种情况下,我从the documentation中获取值,即
testAssemblyVer2: '**\*test*.dll!**\*TestAdapter.dll!**\obj\**'但它也失败了,并显示了类似的错误消息:
...
Test assemblies : **\*test*.dll!**\*TestAdapter.dll!**\obj\**
...
##[warning]No test assemblies found matching the pattern: **\*test*.dll!**\*TestAdapter.dll!**\obj\**.那么如何以正确的方式定义多个模式呢?
发布于 2019-05-16 18:26:22
试试这个:
- task: VSTest@2
inputs:
testAssemblyVer2: |
**\*test.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'https://stackoverflow.com/questions/56166045
复制相似问题