作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Visual Studio Team System 中使用 NUnit 3,他们似乎很难做到这一点。我已将测试程序集步骤添加到构建过程中,并在高级执行选项 -> 自定义测试适配器的路径中,按照帮助中的建议,将 NUnitVisualStudioTestAdapter-2.0.0.vsix 插件的目录路径放入。
无论我做什么,它似乎都没有找到或尝试运行它。它只运行 Visual Studio 测试并报告未找到任何测试。我还尝试将测试适配器作为 NuGet 包和工具的路径放入其中,但这也不起作用。
有没有人设法让 NUnit 在 VSTS 中工作并报告测试结果?
我得到的日志是:
2017-02-07T10:59:26.2778725Z ##[section]Starting: Test Assemblies **\*.Unit.Tests.dll;-:**\obj\**
2017-02-07T10:59:26.2798723Z ==============================================================================
2017-02-07T10:59:26.2798723Z Task : Visual Studio Test
2017-02-07T10:59:26.2798723Z Description : Run tests with Visual Studio test runner
2017-02-07T10:59:26.2798723Z Version : 2.0.10
2017-02-07T10:59:26.2798723Z Author : Microsoft Corporation
2017-02-07T10:59:26.2798723Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)
2017-02-07T10:59:26.2798723Z ==============================================================================
2017-02-07T10:59:28.6268742Z ##[warning]No test assemblies found matching the pattern: **\*.Unit.Tests.dll;-:**\obj\**.
2017-02-07T10:59:28.6998724Z ##[section]Finishing: Test Assemblies **\*.Unit.Tests.dll;-:**\obj\**
2017-02-08T10:44:46.2171630Z ##[section]Starting: Test Assemblies **\*.Unit.Tests.dll;-:**\obj\**
2017-02-08T10:44:46.2251636Z ==============================================================================
2017-02-08T10:44:46.2251636Z Task : Visual Studio Test
2017-02-08T10:44:46.2251636Z Description : Run tests with Visual Studio test runner
2017-02-08T10:44:46.2251636Z Version : 1.0.84
2017-02-08T10:44:46.2251636Z Author : Microsoft Corporation
2017-02-08T10:44:46.2251636Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=624539)
2017-02-08T10:44:46.2251636Z ==============================================================================
2017-02-08T10:44:46.2381636Z Preparing task execution handler.
2017-02-08T10:44:52.1286673Z Executing the powershell script: D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\1.0.84\VSTest.ps1
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddCommand(D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\1.0.84\VSTest.ps1)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - Add inputParameters
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(testAssembly=**\*Tests.dll;-:**\obj\**)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(testFiltercriteria=)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(runSettingsFile=D:\a\1\s)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(overrideTestrunParameters=)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(codeCoverageEnabled=true)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(runInParallel=false)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(vstestLocationMethod=version)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(vsTestVersion=latest)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(vstestLocation=)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(pathtoCustomTestAdapters=D:\a\1\s\packages)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(otherConsoleOptions=)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(testRunTitle=)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(platform=any cpu)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(configuration=release)
2017-02-08T10:44:52.1296976Z ##[debug]PowerShellHandler.Execute - AddParameter(publishRunAttachments=true)
2017-02-08T10:44:52.4586977Z ##[debug]PowerShellHandler.Execute - Invoke
2017-02-08T10:44:52.5076979Z ##[debug]Entering script VSTest.ps1
2017-02-08T10:44:52.5096982Z ##[debug]vsTestVersion = latest
2017-02-08T10:44:52.5096982Z ##[debug]testAssembly = **\*Tests.dll;-:**\obj\**
2017-02-08T10:44:52.5096982Z ##[debug]testFiltercriteria =
2017-02-08T10:44:52.5096982Z ##[debug]runSettingsFile = D:\a\1\s
2017-02-08T10:44:52.5096982Z ##[debug]codeCoverageEnabled = true
2017-02-08T10:44:52.5106990Z ##[debug]pathtoCustomTestAdapters = D:\a\1\s\packages
2017-02-08T10:44:52.5106990Z ##[debug]overrideTestrunParameters =
2017-02-08T10:44:52.5106990Z ##[debug]otherConsoleOptions =
2017-02-08T10:44:52.5106990Z ##[debug]testRunTitle =
2017-02-08T10:44:52.5106990Z ##[debug]platform = any cpu
2017-02-08T10:44:52.5106990Z ##[debug]configuration = release
2017-02-08T10:44:52.5106990Z ##[debug]publishRunAttachments = true
2017-02-08T10:44:52.5106990Z ##[debug]vstestLocation =
2017-02-08T10:44:52.5476990Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.Internal\Microsoft.TeamFoundation.DistributedTask.Task.Internal.psd1'.
2017-02-08T10:44:52.5566992Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.Internal\Microsoft.TeamFoundation.DistributedTask.Task.Internal.psm1'.
2017-02-08T10:44:52.5656993Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.LegacySDK.dll'.
2017-02-08T10:44:52.6656999Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.psd1'.
2017-02-08T10:44:52.6727018Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.psm1'.
2017-02-08T10:44:52.7086999Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.TestResults\Microsoft.TeamFoundation.DistributedTask.Task.TestResults.psm1'.
2017-02-08T10:44:52.7336993Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.111.1\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.CodeCoverage\Microsoft.TeamFoundation.DistributedTask.Task.CodeCoverage.psm1'.
2017-02-08T10:44:52.7406994Z ##[debug]Importing cmdlet 'Invoke-ResultPublisher'.
2017-02-08T10:44:52.7416986Z ##[debug]Importing cmdlet 'Publish-TestResults'.
2017-02-08T10:44:52.7416986Z ##[debug]Importing cmdlet 'Add-BuildArtifactLink'.
2017-02-08T10:44:52.7416986Z ##[debug]Importing cmdlet 'Get-MSBuildLocation'.
2017-02-08T10:44:52.7416986Z ##[debug]Importing cmdlet 'Get-ToolPath'.
2017-02-08T10:44:52.7416986Z ##[debug]Importing cmdlet 'Get-VisualStudioPath'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Get-VssConnection'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Invoke-Ant'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Register-XamarinLicense'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Remove-Environment'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Remove-EnvironmentResources'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Complete-EnvironmentOperation'.
2017-02-08T10:44:52.7427007Z ##[debug]Importing cmdlet 'Complete-EnvironmentResourceOperation'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Complete-ResourceOperation'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Get-Environment'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Get-EnvironmentProperty'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Get-EnvironmentResources'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Get-ExternalIpAddress'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Get-ParsedSessionVariables'.
2017-02-08T10:44:52.7436999Z ##[debug]Importing cmdlet 'Add-TaskIssue'.
2017-02-08T10:44:52.7447001Z ##[debug]Importing cmdlet 'Publish-CodeCoverage'.
2017-02-08T10:44:52.7447001Z ##[debug]Exporting cmdlet 'Enable-CodeCoverage'.
2017-02-08T10:44:52.7447001Z ##[debug]Exporting cmdlet 'Publish-CodeCoverage'.
2017-02-08T10:44:52.7447001Z ##[debug]Importing cmdlet 'Enable-CodeCoverage'.
2017-02-08T10:44:52.7447001Z ##[debug]Importing cmdlet 'Publish-CodeCoverage'.
2017-02-08T10:44:52.8017010Z ##[debug]Invoke - Get-TaskVariable cmdlet
2017-02-08T10:44:52.8107020Z ##[debug]Pattern found in solution parameter. Calling Find-Files.
2017-02-08T10:44:52.8107020Z ##[debug]Calling Find-Files with pattern: **\*Tests.dll;-:**\obj\**
2017-02-08T10:44:52.8147008Z ##[debug]FindFiles.FindMatchingFiles(rootFolder = D:\a\1\s, matchPattern = **\*Tests.dll;-:**\obj\**, includeFiles = True, includeFolders = False
2017-02-08T10:44:52.8177007Z ##[debug]FindFiles.GetMatchingItems(includePatterns.Count = 1, excludePatterns.Count = 1, includeFiles = True, includeFolders = False
2017-02-08T10:44:53.4177077Z ##[debug]FindFiles.FindMatchingFiles - Found 0 matches
2017-02-08T10:44:53.4237058Z ##[debug]Found files:
2017-02-08T10:44:53.4467065Z ##[debug]Processed: ##vso[task.logissue type=warning;code=002004;]
2017-02-08T10:44:53.4467065Z
2017-02-08T10:44:53.4467065Z
2017-02-08T10:44:53.4587060Z ##[warning]No test assemblies found matching the pattern: '**\*Tests.dll;-:**\obj\**'.
2017-02-08T10:44:53.4587060Z ##[debug]Processed: ##vso[task.logissue type=warning]No test assemblies found matching the pattern: '**\*Tests.dll;-:**\obj\**'.
2017-02-08T10:44:53.4607060Z ##[debug]Leaving script VSTest.ps1
2017-02-08T10:44:53.4914646Z ##[section]Finishing: Test Assemblies **\*.Unit.Tests.dll;-:**\obj\**
[command]"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" D:\a\1\s\packages\NUnit3TestAdapter.3.7.0\tools\NUnit3.TestAdapter.dll /EnableCodeCoverage /logger:trx "/TestAdapterPath:\"D:\a\1\s\\\""
Microsoft (R) Test Execution Command Line Tool Version 14.0.25420.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Warning: Using Isolation mode to run tests as required by effective Platform:X86 and .Net Framework:Framework35 settings for test run. Use the /inIsolation parameter to suppress this warning.
Information: NUnit Adapter 3.7.0.0: Test execution started
Information: Running all tests in D:\a\1\s\packages\NUnit3TestAdapter.3.7.0\tools\NUnit3.TestAdapter.dll
Information: NUnit failed to load D:\a\1\s\packages\NUnit3TestAdapter.3.7.0\tools\NUnit3.TestAdapter.dll
Information: NUnit Adapter 3.7.0.0: Test execution complete
Warning: No test is available in D:\a\1\s\packages\NUnit3TestAdapter.3.7.0\tools\NUnit3.TestAdapter.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
最佳答案
自定义测试适配器的路径必须指向 提取 vsix 或提取的 NuGet 包。
使这项工作最简单的方法是添加 NUnit Test Adapter NuGet package 2.x/3.x到您的单元测试项目。 VsTest 任务应自动检测还原到 NuGet 包目录的测试运行程序:
确保 nunit.framework 版本和 NUnit 适配器版本匹配。确保 两者 包被添加到您的测试项目中。
关于nunit - 如何在 VSTS 中使用 NUnit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42086874/
我是一名优秀的程序员,十分优秀!