lundi 19 septembre 2016

Nunit Test fails with Exceptions even when ExpectedException attribute is there

I have this simple test

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

as I knew this test shoudln't be failed because I am expcted to see such an exception, but it fails with this error

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.

I have tried with other types of exceptions too, and result is the same

Aucun commentaire:

Enregistrer un commentaire