Report Bug - or Unit Test false???

Report Bug - or Unit Test false???

Hello,

I evaluate today NetDriven PlugIn and NCover. My problem are the percent values in the tree structure... The unit test is written like ich teste gerade ein bisschen mit NCover rum. Ich bin dabei auf das

[Test, ExcpectedException (typeof (ArgumentException))]
public void testABC () {
  MyObj instance = new MyObj ();
  instance.setBla ("190a90"); // throws an Argument Exception
} // this is for NCover not testing code

NUnit says "All OK" - needed Exception is throwed. NCover says - not all is testet "}" an the percent ist down.

Where is the error?

Thanks


RE: Report Bug - or Unit Test false???

Bastie,

The short answer is that both your unit test and NCover are working correctly. The C# compiler inserts a hidden return statement immediatly before the closing brace, and since an exception is thrown before that statement is executed, NCover says that the statement is uncovered.

The simplest way to get 100% coverage on the function is to run it twice: once with parameters that make it throw and exception, and once with parameters that don't make it throw an exception.

Regards, Stephen