我在 vstest@2 任务的帮助下在 azure 管道上运行测试解决方案。 Pipeline 将测试用例分发到 4 个代理上,然后运行它们。
任务yaml:
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**/*.Tests.dll
searchFolder: '$(System.DefaultWorkingDirectory)'
distributionBatchType: basedOnExecutionTime
runInParallel: true
在运行开始时,我收到一堆这些消息:
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
之后测试开始通过并进一步运行。
对此我有两个问题 - 这些消息实际上意味着什么/我应该以某种方式进行干预吗?
我可以以某种方式禁用这些消息,这样它们就不会向我的运行日志发送垃圾邮件吗?
最佳答案
您可以尝试以下解决方法来解决上述问题,而不是使用 **/*.Tests.dll
尝试使用 **\*test.dll
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test.dll
searchFolder: '$(System.DefaultWorkingDirectory)'
distributionBatchType: basedOnExecutionTime
runInParallel: true
并且还基于MS DOC :
The VsTest task doesn't support running tests that target multiple target frameworks at a time as this is a limitation from the vstest platform side. If you want to run tests that belong to multiple target frameworks, you'll need multiple instances of the vstest task, one per set of dlls that target a particular framework.
有关更多信息,请参阅以下类似问题的链接:
关于c# - VSTEST@2 - 错误找不到测试主机 | Azure管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71955269/