Check that the class Namespace.Foo is 100% covered by tests
A sample rule checking that a particular class is 100% covered by tests; adapt @"Namespace.Foo" and the threshold 100. Requires coverage data imported: https://www.ndepend.com/docs/code-coverage
How to fix
This is a sample rule, there is nothing to fix as is.
CQLinq source
This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.
// <Name>Check that the class Namespace.Foo is 100% covered by tests</Name>
// <Id>ND9913:ExplicitId9913</Id>
warnif count > 0 from t in Application.Types where
(t.FullName == @"Namespace.Foo") &&
t.PercentageCoverage < 100
select new {
t,
t.PercentageCoverage,
Debt = t.NbLinesOfCodeNotCovered.ToMinutes().ToDebt(),
Severity = Severity.High
}
//<Expl>
// The *{0}* is only *{1}* covered by tests while it should be 100% covered.
//</Expl>
//<Desc>
// A sample rule checking that a particular class is 100% covered by tests;
// adapt **@"Namespace.Foo"** and the threshold **100**. Requires coverage
// data imported: https://www.ndepend.com/docs/code-coverage
//</Desc>
//<HowToFix>
// This is a *sample rule*, there is nothing to fix *as is*.
//</HowToFix>
Open in the interactive Rules Explorer · All default rules
Samples of Custom rules / Check Coverage on particular Code Elements: all 4 items
- Check that the namespace N1.N2 is 100% covered by tests ND9911
- Check that the assembly Asm is 100% covered by tests ND9912
- Check that the class Namespace.Foo is 100% covered by tests ND9913
- Check that the method Namespace.Foo.Method(Int32) is 100% covered by tests ND9914