I am trying to gather some good code coverage stats for my C# application, but I would like to ignore the generated SubSonic classes as there is no real point in gathering code coverage statistics for these functions.
I have edited the ActiveRecord.tt file to include the [ExcludeFromCodeCoverage] attribute on every method and property, and this has removed most of the irrelevant results in my code coverage window. However, despite having the code coverage exclusion attribute, lambda expressions within properties are being marked as not covered. As an example:
[ExcludeFromCodeCoverage]
int GetValue
{
get
{
this.SomeMethod(); // this is excluded
return this.Find(x => x.Value == this._Value); // this.Find is excluded
// but x => x.Value == ...
// is not.
}
}
This only occurs in properties. Lambda expressions are ignored within methods, as expected.
Now, to me, this is rather annoying, but not necessarily fatal, as I can just ignore these expressions as I browse my code coverage list. However, our client has demanded that our code coverage level be above 95%. It is unlikely that I will be able to make them understand that this statistic is largely useless.
I could automatically generate unit tests along with the ActiveRecord.tt file, but this is hardly ideal.
Thank you for your time.