Check that the namespace N1.N2 is 100% covered by tests
A sample rule checking that a particular namespace is 100% covered by tests; adapt @"N1.N2" 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 namespace N1.N2 is 100% covered by tests</Name>
// <Id>ND9911:ExplicitId9911</Id>
warnif count > 0 from n in Application.Namespaces where
(n.Name == @"N1.N2") &&
n.PercentageCoverage < 100
select new {
n,
n.PercentageCoverage,
Debt = n.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 namespace is 100% covered by
// tests; adapt **@"N1.N2"** 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