当项目

时间:2017-11-27 15:38:05

标签: macos visual-studio

当我尝试运行我的单元测试时,我一直有一些奇怪的行为,之前我已经能够运行我的测试而不添加另一个,因为我遇到了类似的错误,但现在我可以&#39 ;运行任何,我在运行时遇到此错误;

Unable to write data to the transport connection: The socket has been shut down.
Stack trace:
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000c3] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:602 
  at System.IO.Stream.WriteByte (System.Byte value) [0x0000b] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/io/stream.cs:770 
  at System.IO.BinaryWriter.Write (System.Byte value) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/io/binarywriter.cs:152 
  at System.IO.BinaryWriter.Write7BitEncodedInt (System.Int32 value) [0x00004] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/io/binarywriter.cs:427 
  at System.IO.BinaryWriter.Write (System.String value) [0x0001b] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/io/binarywriter.cs:370 
  at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.SocketCommunicationManager.WriteAndFlushToChannel (System.String rawMessage) [0x0001b] in <b490783f77944638be7b669258bc82b9>:0 
  at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.SocketCommunicationManager.SendMessage (System.String messageType, System.Object payload) [0x0000e] in <b490783f77944638be7b669258bc82b9>:0 
  at MonoDevelop.DotNetCore.UnitTesting.DotNetCoreTestPlatformAdapter.GetProcessStartInfo (System.Collections.Generic.IEnumerable`1[T] testAssemblies) [0x00019] in /Users/builder/data/lanes/5144/b604c37c/source/monodevelop/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.UnitTesting/DotNetCoreTestPlatformAdapter.cs:450 
  at MonoDevelop.DotNetCore.UnitTesting.DotNetCoreTestPlatformAdapter.DebugTests (MonoDevelop.UnitTesting.TestContext testContext, MonoDevelop.DotNetCore.UnitTesting.IDotNetCoreTestProvider testProvider, System.String testAssemblyPath) [0x0002b] in /Users/builder/data/lanes/5144/b604c37c/source/monodevelop/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.UnitTesting/DotNetCoreTestPlatformAdapter.cs:417 

对于大量的复制和粘贴代码感到抱歉。我尝试了多种解决方案,例如清理重建,重新加载项目,将测试移动到不同的项目,不同的类等等,并没有解决这个问题。我唯一能想到的就是清除临时文件,但我无法在网上找到任何我需要在Mac上清除文件的信息。

编辑1: 这似乎只发生在我有9次以上的测试时,我重新安装了visual studio,在项目上完成了dotnet还原,这是我在谷歌上可以找到的,我相信上面的错误信息只是一个问题之后真实的我认为是;

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
   at Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.ExecuteAsync()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.RunTests(TestRunCriteria testRunCriteria, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.RunTests(TestRunRequestPayload testRunRequestPayload, ITestHostLauncher testHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig)
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass18_0.<StartTestRun>b__0()

调试其中一个显示为https://imgur.com/a/1holi的失败测试时,会收到此错误。

编辑2:当我创建一个新的XUnit测试项目时,也会发生这种情况。正如您在9张测试的图像中所看到的,它们被发现并运行正常:https://imgur.com/a/XnOPW。但是,一旦添加第十个测试,我得到:https://imgur.com/a/juY6v。在运行这些测试时,输出窗口显示:https://imgur.com/a/BblXy

编辑3:经过一番挖掘后,我发现了一些有关此问题的信息,这些信息引导我找到解决方案。问题是.NET核心项目单元测试有一个将它们限制为9的错误,这在Visual Studio的7.3版本中得到修复,而不是当前版本。将我的更新更改为Alpha版本后,我已经下载了7.3并修复了我的问题;有关这方面的更多信息,请访问https://developercommunity.visualstudio.com/content/problem/90031/test-pad-breaks-after-exceeding-9-test-methods-xun.html

1 个答案:

答案 0 :(得分:0)

正如我的编辑心理 - 经过一番挖掘后,我发现了一些有关此问题的信息,这些信息引出了我的解决方案。问题是.NET核心项目单元测试有一个将它们限制为9的错误,这在Visual Studio的7.3版本中得到修复,而不是当前版本。将我的更新更改为Alpha版本后,我已经下载了7.3并修复了我的问题;有关这方面的更多信息,请访问https://developercommunity.visualstudio.com/content/problem/90031/test-pad-breaks-after-exceeding-9-test-methods-xun.html