5

当使用 Visual Studio 团队服务构建 Visual Studio 解决方案时,它运行单元测试,使用 nunit 3 NUnit3TestAdapter 在 nunit 3 中编写,它开始运行测试。

它给出的错误是:错误:路径中有非法字符。

完整输出如下

2016-02-11T17:02:40.8514411Z Executing the powershell script: C:\BuildAgent\tasks\VSTest\1.0.29\VSTest.ps1
2016-02-11T17:02:41.1483135Z ##[debug]Calling Invoke-VSTest for all test assemblies
2016-02-11T17:02:41.2108131Z Working folder: C:\BuildAgent\_work\5
2016-02-11T17:02:41.2108131Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\BuildAgent\_work\5\s\xxxxxxxxxxTests\bin\Release\xxxxxxxxxxTests.dll"  /logger:trx /TestAdapterPath:"C:\BuildAgent\_work\5\s"
2016-02-11T17:02:41.5240692Z Microsoft (R) Test Execution Command Line Tool Version 14.0.24720.0
2016-02-11T17:02:41.5240692Z Copyright (c) Microsoft Corporation.  All rights reserved.
2016-02-11T17:02:42.1326930Z Starting test execution, please wait...
2016-02-11T17:02:46.4921857Z Information: NUnit Adapter 3.0.8.0 executing tests is started
2016-02-11T17:02:46.5077303Z Information: Running all tests in C:\BuildAgent\_work\5\s\xxxxxxxxxxTests\bin\Release\xxxxxxxxxxTests.dll
2016-02-11T17:02:46.6327336Z Information: NUnit Adapter 3.0.8.0 executing tests is finished
2016-02-11T17:02:46.6327336Z ##[error]Error: Exception System.ArgumentException, Exception thrown executing tests
2016-02-11T17:02:46.6327336Z ##[error]
2016-02-11T17:02:46.6327336Z ##[error]Error: Illegal characters in path.
2016-02-11T17:02:46.6327336Z ##[error]
2016-02-11T17:02:46.7108474Z Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
2016-02-11T17:02:46.8358887Z ##[error]VSTest Test Run failed with exit code: 1
2016-02-11T17:02:46.8514965Z ##[warning]No results found to publish.

我们有一个内部构建代理,但我认为这不会产生影响。

构建测试步骤截图

您可以提供的任何建议表示赞赏。

4

2 回答 2

6

FWIW,我按照提示和技巧打开了详细日志记录并得到了这个:

2016-02-23T14:45:49.5620657Z Information: Running all tests in C:\TFS2015\_work\3\s\BlaBlaTests\bin\Debug\BlaBlaTests.dll
2016-02-23T14:45:49.6088663Z ##[error]Error: Exception thrown executing tests
2016-02-23T14:45:49.6088663Z ##[error]
2016-02-23T14:45:49.6088663Z ##[error]Error: System.ArgumentException: Illegal characters in path.
2016-02-23T14:45:49.6088663Z ##[error]   at System.IO.Path.CheckInvalidPathChars(String path)
2016-02-23T14:45:49.6088663Z ##[error]   at System.IO.Path.Combine(String path1, String path2)
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.Engine.Services.ExtensionService.ProcessAddinsFile(DirectoryInfo baseDir, String fileName)
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.Engine.Services.ExtensionService.FindExtensionsInDirectory(DirectoryInfo startDir)
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.Engine.Services.ExtensionService.StartService()
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.Engine.Services.ServiceManager.StartServices()
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.Engine.TestEngine.Initialize()
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.Engine.TestEngine.GetRunner(TestPackage package)
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.VisualStudio.TestAdapter.NUnitTestAdapter.GetRunnerFor(String assemblyName)
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyName, IFrameworkHandle frameworkHandle)
2016-02-23T14:45:49.6088663Z ##[error]   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
2016-02-23T14:45:49.6088663Z ##[error]
2016-02-23T14:45:49.6088663Z Information: NUnit Adapter 3.0.8.0 executing tests is finished

这与%LOCALAPPDATA%\NUnit\Nunit30Settings.xml被访问相关,但可能不相关。ExtensionService这里

问题#117#118与RobertK66提供的修复相关:

如果您将版本 3.0.8.0 安装为 Nuget 包,则在 packages\NUnit3TestAdapter.3.0.8-ctp-8\lib 文件夹中安装了一个损坏的(不是空的!)“ignore.addins”文件。早期版本确实安装了一个 0byte 的空文件!

在 /packages/NUnit3TestAdapter.3.0.8-ctp-8\lib 文件夹中删除此文件的内容并删除 \AppData\Local\Temp\VisualStudioTestExplorerExtensions 下的适配器的缓存版本后...一切正常!

于 2016-02-23T15:51:42.883 回答
1

我在构建过程中使用NUnit3 测试适配器 Nuget 包时遇到了这个问题。我通过安装NUnit3 测试适配器解决了这个问题,并将所有安装的文件上传到版本控制并将其用作测试适配器。

由于您使用的是本地构建代理。您可以轻松地在构建代理上安装 NUnit3 测试适配器,并按照错误消息的指示使用“/UseVsixExtensions:true”参数。 在此处输入图像描述

于 2016-02-15T03:39:15.487 回答