【发布时间】:2018-12-28 11:06:25
【问题描述】:
我是 NUNIT 的新手,我正在经历以下奇怪的行为。
在我的测试项目中,我有这个测试类:
namespace Tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test1()
{
Assert.Pass("PASSED");
}
}
}
目前只包含 Test1() 每次执行时都应该通过的方法(因为我使用的是 Assert.Pass() 方法。
如果我运行此测试,它可以正常工作并且测试通过(Visual Studio 测试资源管理器中的绿色条)。
但是如果我尝试调试此方法(在 Assert.Pass("PASSED"); 行上放置一个断点,它会给我这个尝试执行 Pass() 方法的异常:
Exception thrown: 'NUnit.Framework.SuccessException' in nunit.framework.dll
An exception of type 'NUnit.Framework.SuccessException' occurred in nunit.framework.dll but was not handled in user code
PASSED
无论如何,测试似乎通过了。但是为什么我在调试模式下会得到这个异常呢?
【问题讨论】:
标签: c# .net unit-testing nunit