Exclude lines from code coverage.

Hi Community

I’ve just started using DotCover and already have found a problem I can’t solve.

In my code I’ve a few lines which never will be executed,

for example a switch case statement which needs a default label.

public static class LogEx {      public static My.LogLevel ToLogLevel( this LogLevel level )      {           switch ( level )           {                case LogLevel.Debug:                     return My.LogLevel.Debug;                case LogLevel.Error:                     return My.LogLevel.Error;                case LogLevel.Fatal:                     return My.LogLevel.Fatal;                case LogLevel.Info:                     return My.LogLevel.Info;                case LogLevel.Off:                     return My.LogLevel.Off;                case LogLevel.Trace:                     return My.LogLevel.Trace;                case LogLevel.Warn:                     return My.LogLevel.Warn;                default:                     throw new ArgumentOutOfRangeException( $"{level} is not supported", nameof( level ) );           }      } }

Can I tell DotCover to ignore some lines (maybe with comments just like R#)?

Thanks for your help

Comment actions Permalink


Currently this scenario is not supported. Here is a corresponding request in our tracker: https://youtrack.jetbrains.com/issue/DCVR-4723
You are welcome to subscribe for the updates.


Comment actions Permalink

I don't think that feature is what I am asking for.

I’ve created a new ticket here: https://youtrack.jetbrains.com/issue/DCVR-7710

Comment actions Permalink


Maybe you can put [ExcludeFromCodeCoverage] above the function. It's not for specific lines but it should be ok in this case.


Please sign in to leave a comment.