.net - 为什么使用 NUnit/TestDriven.Net2.0 测试会崩溃?

标签 .net nunit stack-overflow executable

我有一组运行良好的 TestFixtures。我在装置中添加了一个新的测试,但由于某种原因,我无法运行它。其他类(class)甚至同一类(class)的其他测试都运行良好。

  • NUnit GUI/TestDriven 均崩溃

如果我从 NUnit GUI 运行,我会收到此错误:

NUnit 已停止处理此消息

Description:
  Stopped working

Problem signature:
  Problem Event Name:   CLR20r3
  Problem Signature 01: nunit.exe
  Problem Signature 02: 2.5.3.9345
  Problem Signature 03: 4b2334ce
  Problem Signature 04: Engine
  Problem Signature 05: 1.0.0.0
  Problem Signature 06: 4b51c6fe
  Problem Signature 07: ad
  Problem Signature 08: 0
  Problem Signature 09: System.StackOverflowException
  OS Version:   6.0.6001.2.1.0.768.3
  Locale ID:    2057

在VS2008中使用TestDriven.Net 2.0,出现此错误:

TestDriven.Net 2.0 已停止工作

Description:
  Stopped working

    Problem signature:
      Problem Event Name:   CLR20r3
      Problem Signature 01: processinvocation86.exe
      Problem Signature 02: 3.0.2556.0
      Problem Signature 03: 4af0254b
      Problem Signature 04: Engine
      Problem Signature 05: 1.0.0.0
      Problem Signature 06: 4b51c6fe
      Problem Signature 07: ad
      Problem Signature 08: 0
      Problem Signature 09: System.StackOverflowException
      OS Version:   6.0.6001.2.1.0.768.3
      Locale ID:    2057

最佳答案

嗯,很明显你正在导致堆栈溢出。 StackOverflowException 是一个致命异常,它会导致 CLR 崩溃 - 这就是您看到该问题的原因。

我建议您调试测试以找出堆栈溢出的原因。这通常是一个递归问题。例如,如果您的属性中有拼写错误:

 private readonly int age;

 public int Age
 {
     get { return Age; } // should be "return age;"
 }

这会导致堆栈溢出 - 但不小心编写的递归方法也会导致堆栈溢出。

关于.net - 为什么使用 NUnit/TestDriven.Net2.0 测试会崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2077596/

相关文章:

.net - 如何在.NET中使用ColorMatrix改变亮度、颜色、饱和度、色调

.net - 如何获取消息契约(Contract)以在正文而不是 header 中发送 SOAP 操作

c# - Linq Group By 两个可能不同或相同的属性

c# - 如何将 nunit 测试结果包含在 sonarcube 4.5.1 c# 插件 3.3 sonar-project.properties 文件中?

gdb - 调试由 pwntools 打开的程序

c# - 为什么MySQL在C#代码中返回总是1,但在存储过程中测试时却不是?

asp.net - 无法在单元测试中检查响应 header

c++ - 使用 NUnit 在 VS 2010 中调试 native /托管 C++

.net - IIS应用程序池随机崩溃是由堆栈溢出引起的

c++ - 没有溢出的无限递归 - 这可能吗?