Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 使用Visual Studio Online生成服务器发现xUnit.net测试时出现异常_Unit Testing_Tfsbuild_Xunit.net_Azure Devops - Fatal编程技术网

Unit testing 使用Visual Studio Online生成服务器发现xUnit.net测试时出现异常

Unit testing 使用Visual Studio Online生成服务器发现xUnit.net测试时出现异常,unit-testing,tfsbuild,xunit.net,azure-devops,Unit Testing,Tfsbuild,Xunit.net,Azure Devops,我正在使用Xunit.net和Visual Studio Online托管的构建。我的测试正在本地和构建服务器上被发现并正常运行。但是在构建服务器上,我得到了这个异常(导致构建达到“部分成功”状态)。这很奇怪,因为我所有的测试实际上都被发现并运行 [xUnit.net 00:00:01.3170293] Exception discovering tests from C:\a\bin\xunit.runner.visualstudio.testadapter.dll: System.IO.Fi

我正在使用Xunit.net和Visual Studio Online托管的构建。我的测试正在本地和构建服务器上被发现并正常运行。但是在构建服务器上,我得到了这个异常(导致构建达到“部分成功”状态)。这很奇怪,因为我所有的测试实际上都被发现并运行

[xUnit.net 00:00:01.3170293] Exception discovering tests from C:\a\bin\xunit.runner.visualstudio.testadapter.dll: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value HKLM\Software\Microsoft\Fusion!EnableLog to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Xunit.Sdk.Executor.EnumerateTests..ctor(Executor executor, Object _handler)$$RethrowMarker$$   at ExceptionExtensions.RethrowWithNoStackTraceLoss(Exception ex)
   at Xunit.RemoteAppDomainManager.CreateObjectTObject
   at Xunit.Xunit1Executor.EnumerateTests(ICallbackEventHandler handler)
   at Xunit.Xunit1.Find(Predicate`1 filter, Boolean includeSourceInformation, IMessageSink messageSink)
   at Xunit.Xunit1.Find(Boolean includeSourceInformation, IMessageSink messageSink)
   at Xunit.XunitFrontController.Find(Boolean includeSourceInformation, IMessageSink messageSink)
   at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.GetTests(IEnumerable`1 sources, IMessageLogger logger, XunitVisualStudioSettings settings, Stopwatch stopwatch)

See http://go.microsoft.com/fwlink/?LinkId=254169
我在测试项目中安装了以下nuget软件包:

  • xunit 1.9.2
  • xunit.runner.visualstudio 0.99.2
其他单元测试框架,如MS Test和NUnit,工作正常。这让我觉得问题在于Xunit.net,而不是Visual Studio Online

我还在xUnit.net GitHub上打开了一个问题,但它仍然没有解决。


我怎样才能让它工作?有人知道解决方法吗?是否可以以某种方式抑制错误消息?

testrunner尝试在
xunit.runner.visualstudio.testadapter.dll
中发现单元测试。为什么?因为它与
*.test*.dll
的默认测试源规范相匹配

当将默认测试源规范更改为
*.tests.dll
或其他更具体的内容时,它将起作用


来源:

我在Visual Studio Online build中使用NUnit测试适配器时遇到了类似的情况,并按照上面的建议重命名了通配符,同时也修复了它。我收到的错误消息:
未找到C:\a\bin\NUnit.VisualStudio.TestAdapter.dll的依赖程序集Microsoft.VisualStudio.TestPlatform.ObjectModel,版本=11.0.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a。如果不是NUnit项目,则可以忽略。
希望这可以帮助除NUnit以外的其他人偶然发现此问题。