本文介绍了Visual Studio 2017在单元测试期间崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从2015年到2017年并开始运行既定的单元测试。 2017年崩溃:


[4/2/2018 3:55:30 PM错误] System.NullReferenceException:对象引用未设置为对象的实例。

  在Microsoft.VisualStudio.TestWindow.Model.Observable.OnPropertyChanged(字符串信息)

  在Microsoft.VisualStudio.TestWindow.Model.Test.UpdateDataHasVisibleChange(TestData newTestData,Int32 index)

  在Microsoft.VisualStudio.TestWindow.Model.VirtualTestCollection.CreateTest(Int32索引,TestData testData,Dictionary`2 knownTests)

  在Microsoft.VisualStudio.TestWindow.Model.VirtualTestCollection.RefreshTests(List`1& items)

  在Microsoft.VisualStudio.TestWindow.Model.VirtualTestCollection.Refresh()

  在Microsoft.VisualStudio.TestWindow.Model.TestGroup.Refresh(CancellationToken令牌)

  在Microsoft.VisualStudio.TestWindow.Model.TestGroupCollection。< RefreshCollection> d__41.MoveNext()

---从抛出异常的上一个位置开始的堆栈跟踪结束---

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在Microsoft.VisualStudio.TestWindow.Model.TestGroupCollection。<> c__DisplayClass51_0。<<< ProcessChange> b__0> d.MoveNext()

---来自先前位置的堆栈跟踪结束被扔了---

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在Microsoft.VisualStudio.TestWindow.Model.TestGroupCollection。< AwaitChangeComplete> d__50.MoveNext()

---从抛出异常的上一个位置开始的堆栈跟踪结束---

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在Microsoft.VisualStudio.TestWindow.Model.VirtualReadOnlyTestDataStore。< ProcessChange> d__57.MoveNext()

---从抛出异常的上一个位置开始的堆栈跟踪结束---

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在Microsoft.VisualStudio.TestWindow.Model.VirtualReadOnlyTestDataStore。< ProcessChange> d__56.MoveNext()

---从抛出异常的上一个位置开始的堆栈跟踪结束---

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在Microsoft.VisualStudio.TestWindow.Model.VirtualReadOnlyTestDataStore。<> c__DisplayClass55_0。<<< OnUnitTestChanged> b__1> d.MoveNext()

---来自先前位置的堆栈跟踪结束被扔了---

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在Microsoft.VisualStudio.TestWindow.Extensibility.ILoggerExtensions。< CallWithCatchAsync> d__4`1.MoveNext()


如果我关闭VS并重新打开解决方案,单元测试将会运行。


在调试模式下,在Release模式下传递的单元测试也会失败。当我调试测试时,它们在不同的位置失败,并且似乎没有调用shim函数。



解决方案

I am moving from 2015 to 2017 and running established unit tests. 2017 is crashing:

[4/2/2018 3:55:30 PM Error] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.Model.Observable.OnPropertyChanged(String info)
   at Microsoft.VisualStudio.TestWindow.Model.Test.UpdateDataHasVisibleChange(TestData newTestData, Int32 index)
   at Microsoft.VisualStudio.TestWindow.Model.VirtualTestCollection.CreateTest(Int32 index, TestData testData, Dictionary`2 knownTests)
   at Microsoft.VisualStudio.TestWindow.Model.VirtualTestCollection.RefreshTests(List`1& items)
   at Microsoft.VisualStudio.TestWindow.Model.VirtualTestCollection.Refresh()
   at Microsoft.VisualStudio.TestWindow.Model.TestGroup.Refresh(CancellationToken token)
   at Microsoft.VisualStudio.TestWindow.Model.TestGroupCollection.<RefreshCollection>d__41.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Model.TestGroupCollection.<>c__DisplayClass51_0.<<ProcessChange>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Model.TestGroupCollection.<AwaitChangeComplete>d__50.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Model.VirtualReadOnlyTestDataStore.<ProcessChange>d__57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Model.VirtualReadOnlyTestDataStore.<ProcessChange>d__56.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Model.VirtualReadOnlyTestDataStore.<>c__DisplayClass55_0.<<OnUnitTestChanged>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Extensibility.ILoggerExtensions.<CallWithCatchAsync>d__4`1.MoveNext()

If I close VS and reopen the solution the unit tests will run.

Also unit tests that pass in Release mode are failing in Debug mode. When I debug the test, they fail in a different location and the shim function does not appear to be called.

解决方案


这篇关于Visual Studio 2017在单元测试期间崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 15:03