Code Coverage and Exceptions

time to read 1 min | 126 words

One of the more annoying this in code coverage in .Net is that it doesn't consider the line where an exception was thrown to be visited.

public void SomeMethod()
   throw new Exception(); //Will appear as unvisited to the code coverage

Both NCover and VS 2005 exhibit this behavior, and I assume that this has to do with the way they work, via the profiling API. Anyone can say what the reason for that is?