即使存在ExpectedException属性,Nunit Test也会以异常失败

时间:2016-09-18 22:39:48

标签: unit-testing nunit nunit-3.0

我有这个简单的测试

 [Test]
 [ExpectedException(typeof(Exception))]
 public void Test2()
 {
     throw new Exception();
 }

因为我知道这个测试失败了因为我被指示看到这样的异常,但它失败并出现此错误

Test Name:  Test2
Test FullName:  Framework.Tests.Service.BaseServiceTest.Test2
Test Source:    c:\Framework.Tests\Service\BaseServiceTest.cs : line 75
Test Outcome:   Failed
Test Duration:  0:00:00.189

Result StackTrace:  at Framework.Tests.Service.BaseServiceTest.Test2() in c:\Framework.Tests\Service\BaseServiceTest.cs:line 76
Result Message: System.Exception : Exception of type 'System.Exception' was thrown.

我也尝试过其他类型的异常,结果是相同的

0 个答案:

没有答案