TestMethod 使 MSTest 中的测试运行器崩溃
TestMethod is crashing the Test Runner in MSTest
我正在 运行在 MSTest 中进行一组测试,在完成特定测试和 运行s TestCleanup 后发生异常,这导致测试 运行ner崩溃而不是 运行 任何更多的测试。我有五个测试可以做到这一点,它们看起来与 运行 正确的一些测试几乎相同。
这是输出测试中的错误window:
[11/16/2020 5:36:14 PM Informational] ------ Run test started ------
[11/16/2020 5:36:55 PM Error] An exception occurred while invoking executor 'executor://mstestadapter/v2': Object reference not set to an instance of an object.
[11/16/2020 5:36:59 PM Informational] ========== Run test finished: 0 run (0:00:45.5280936) ==========
这是我在输出调试中看到的 window:
Exception thrown: 'System.NullReferenceException' in log4net.dll
Exception thrown: 'System.NullReferenceException' in Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
Exception thrown: 'System.NullReferenceException' in Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
'testhost.x86.exe' (CLR v4.0.30319: Domain 3): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
…
The thread 0xdd68 has exited with code 0 (0x0).
Exception thrown: 'System.NullReferenceException' in Microsoft.TestPlatform.PlatformAbstractions.dll
The thread 0xdc80 has exited with code 0 (0x0).
The program '[57424] testhost.x86.exe' has exited with code 0 (0x0).
我可以看到 log4net 在 app.config 中设置为 OFF。导致测试 运行ner 崩溃的问题可能是什么?
log4net
是罪魁祸首。记录器已初始化,测试后需要适当清理。
[TestCleanup]
public virtual void TestCleanup()
{
//// To avoid this error caused by log4net v1.2.13: An exception occurred while invoking executor 'executor://mstestadapter/v1': Type is not resolved for member 'log4net.Util.PropertiesDictionary,log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'.
CallContext.FreeNamedDataSlot("log4net.Util.LogicalThreadContextProperties");
}
我正在 运行在 MSTest 中进行一组测试,在完成特定测试和 运行s TestCleanup 后发生异常,这导致测试 运行ner崩溃而不是 运行 任何更多的测试。我有五个测试可以做到这一点,它们看起来与 运行 正确的一些测试几乎相同。
这是输出测试中的错误window:
[11/16/2020 5:36:14 PM Informational] ------ Run test started ------
[11/16/2020 5:36:55 PM Error] An exception occurred while invoking executor 'executor://mstestadapter/v2': Object reference not set to an instance of an object.
[11/16/2020 5:36:59 PM Informational] ========== Run test finished: 0 run (0:00:45.5280936) ==========
这是我在输出调试中看到的 window:
Exception thrown: 'System.NullReferenceException' in log4net.dll
Exception thrown: 'System.NullReferenceException' in Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
Exception thrown: 'System.NullReferenceException' in Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
'testhost.x86.exe' (CLR v4.0.30319: Domain 3): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
…
The thread 0xdd68 has exited with code 0 (0x0).
Exception thrown: 'System.NullReferenceException' in Microsoft.TestPlatform.PlatformAbstractions.dll
The thread 0xdc80 has exited with code 0 (0x0).
The program '[57424] testhost.x86.exe' has exited with code 0 (0x0).
我可以看到 log4net 在 app.config 中设置为 OFF。导致测试 运行ner 崩溃的问题可能是什么?
log4net
是罪魁祸首。记录器已初始化,测试后需要适当清理。
[TestCleanup]
public virtual void TestCleanup()
{
//// To avoid this error caused by log4net v1.2.13: An exception occurred while invoking executor 'executor://mstestadapter/v1': Type is not resolved for member 'log4net.Util.PropertiesDictionary,log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'.
CallContext.FreeNamedDataSlot("log4net.Util.LogicalThreadContextProperties");
}