【发布时间】:2011-10-12 00:41:38
【问题描述】:
我在从 VisualStudio 调试 NUnit 测试时遇到问题。我创建了一个空项目(Console Application),然后添加了对 NUnit 库的引用并编写了一个简单的测试。
namespace ReimplementingLinq.Tests
{
[TestFixture]
public class WhereTest
{
[Test]
public void SimpleFiltering()
{
int[] source = { 1, 2, 3, 4, 2, 8, 1 };
var result = source.Where(val => val < 4);
int[] expected = {1,2,3,4};
CollectionAssert.AreEqual(expected, result);
}
}
}
接下来,我遵循了此链接中给出的建议 How do I run NUnit in debug mode from Visual Studio? 但该主题中的任何解决方案都不适合我。在执行测试时,我的任何断点都没有被命中。我尝试通过附加到流程以及使用带有参数的外部程序运行项目来测试解决方案。
我可以做些什么来调试我的单元测试?
【问题讨论】:
-
你是说你正在附加到 nunit.exe 进程,在 nunit IDE 中运行测试但你的断点没有被命中?
-
NUnit 是否可能试图在不同的框架版本下运行?试试以下链接:stackoverflow.com/q/3542904/13188 和 stackoverflow.com/q/930438/13188
-
我得到了它与我在这里发布的答案:stackoverflow.com/questions/13348613/…
标签: c# unit-testing testing nunit