有没有人在 Visual Studio IDE 2019 (16.9.3) 和通过 vstest.console.exe (16.9.1) 的命令行中遇到以下单元测试执行错误?
即使在安装了最新的 .NET 5.0.5 (5.0.202 SDK) 之后,也会发生这种情况。
我什至尝试调试到 Newtonsoft 13.0.1 但只是发现构造函数刚刚退出并在此处抛出异常。它甚至没有在这里击中 JContainer ctor 。
相同的逻辑在运行时运行良好,但不能通过/在测试 [Fact] 函数中运行。我将其提取出来以确保它是孤立的并且不会经过任何模拟/伪造。看起来像是某处的 .NET 测试引擎?
失败的单元测试项目使用以下内容:
- xunit (2.4.1)
- xunit.runner.visualstudio (2.4.3)
- NSubstitute (4.2.2)
- mstest.testframework (2.2.3)
- 微软.NET.Test.Sdk (16.9.4)
- Microsoft.QualityTools.Testing.Fakes (16.7.4-beta.20330.2)
它是一个 .NET FW 4.6.2 目标项目,带有 .NET SDK 样式的 csproj 文件设置,而不是旧的 .NET FW 结构。
来自单元测试命令行执行的堆栈跟踪:
Error Message:
System.InvalidProgramException : Common Language Runtime detected an invalid program.
Stack Trace:
at Newtonsoft.Json.Linq.JContainer..ctor(JContainer other)
at Newtonsoft.Json.Linq.JObject..ctor(JObject other)
at Newtonsoft.Json.Linq.JObject.CloneToken()
at Newtonsoft.Json.Linq.JContainer.EnsureParentToken(JToken item, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JContainer.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JContainer.TryAddInternal(Int32 index, Object content, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JContainer.Add(Object content)
at Newtonsoft.Json.Linq.JArray.Add(JToken item)
at at MyUnitTests.<MyTest_HasNeededData_ReturnsData>d__45.MoveNext() in XXXXXXXXXXXXXXXXXXXXXXX:line 643
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
请帮忙!!!提前致谢。