NCover and ExpectedException

NCover and ExpectedException

Hi all,

Currently evaluating NCover, seems exactly the sort of tool we're looking for. However, we use NUnit testing extensively and have a number of tests that expect an exception to be thrown. We don't want to have to exclude these tests from the coverage report, so is there any workaround?

I've googled the web and the NCover forums and am yet to see any solution other than exclusion.


RE: NCover and ExpectedException

this seems like a stupid question, but why do you need a workaround, and what is the workaround for? IOW, what is the problem with the "ExpectedException" tests makes them mess up coverage?


RE: NCover and ExpectedException

Ok, I guess I should have explained what I mean a bit better.

If you have a test that is marked as [ExpectedException] and it passes, i.e. it threw an exception as expected, then it never reaches the final line of the test and therefore NCover says the method is not fully covered.

So, my question is, as this test is correct, is there any workaround for NCover to look at the fact it is a test of type ExpectedException, and report full coverage?


RE: NCover and ExpectedException

yes! run in release mode. when a program is compiled in debug mode, the compiler inserts extra symbols to help make the step-next command in debugging a little more user-friendly. For this specific case, the the compiler creates a symbol point at the very end of the method so that someone debugging can look at a variable's final state right before exiting the method. Compiling in release mode removes the extra symbol points.


RE: NCover and ExpectedException

Ha! So simple :)

Thanks very much for your help.


RE: NCover and ExpectedException

glad to be of help