AxoCover
AxoCover copied to clipboard
Question: exclude .ctor from coverage
Hey, I was wondering if there is a way to exclude .ctor from coverage? I'm using Visual Studio 2017 if it makes any difference.
I have tried to read the documentation, but couldn't find out how to do it. I really appreciate this tool =) It's great and even becomes better the more i learn about it. Thanks!

I dont think it's a good idea to exclude ctor from coverage. we can test if some of dependencies are null or someting else if we are using a constructor dependency injection.
I hope you see what i'm explaining :)
Best regards.
Since AxoCover uses OpenCover and OpenCover respects the ExcludeFromCodeCoverageAttribute you can mark your .ctor with ExcludeFromCodeCoverage but I do not recommend it (otherwise you would not know which of your .ctors is covered and which is not.
public class MyClass
{
private Logger logger;
[ExcludeFromCodeCoverage]
public MyClass()
{
this.logger = new Logger();
}
[ExcludeFromCodeCoverage]
public MyClass(ILogger logger)
{
this.logger = logger;
}
}
You can change this behaviour in the settings
