Assemblies and Namespaces should be tested
Lists assemblies and namespaces not covered at all by unit tests (a matched assembly's children namespaces are not matched).
Its goal is to inform of large untested code elements — not to collide with Code should be tested, which details uncovered code, Debt and Annual Interest per method. Hence Debt is only 4 minutes per issue and severity is Low.
Its goal is to inform of large untested code elements — not to collide with Code should be tested, which details uncovered code, Debt and Annual Interest per method. Hence Debt is only 4 minutes per issue and severity is Low.
How to fix
Write unit and integration tests to cover, even partially, the matched elements. Then use Code should be tested, New Types and Methods should be tested and Methods refactored should be tested to write tests where they matter most, refactoring for testability if needed.
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>Assemblies and Namespaces should be tested</Name>
// <Id>ND1603:AssembliesNamespacesAndTypesShouldBeTested</Id>
warnif count > 0
from elem in JustMyCode.Assemblies.Concat(JustMyCode.Namespaces.Cast<ICodeElementParent>())
where elem.NbLinesOfCode > 0 &&
elem.PercentageCoverage == 0 &&
elem.Parent.PercentageCoverage != 0
orderby elem.NbLinesOfCode descending
select new {
elem,
elem.NbLinesOfCodeNotCovered,
Debt = 4.ToMinutes().ToDebt(),
Severity = Severity.Low
}
//<Expl>
//None of the {1} statement{1?:s} of the *{0}* {1?is:are} covered by a test.
//This issue will be considered as fixed when a first test will be written.
//Issues of the rule *Code should be tested* provide the details of statements to cover for each method.
//</Expl>
//<Desc>
// Lists assemblies and namespaces not covered at all by unit tests (a
// matched assembly's children namespaces are not matched).
//
// Its goal is to inform of large untested code elements — not to collide
// with **Code should be tested**, which details uncovered code, *Debt* and
// *Annual Interest* per method. Hence *Debt* is only 4 minutes per issue and
// severity is *Low*.
//</Desc>
//
//<HowToFix>
// Write unit and integration tests to cover, even partially, the matched
// elements. Then use **Code should be tested**, **New Types and Methods
// should be tested** and **Methods refactored should be tested** to write
// tests where they matter most, refactoring for testability if needed.
//</HowToFix>
Open in the interactive Rules Explorer · All default rules
Code Coverage: all 15 items
- Code should be tested ND1600
- New Types and Methods should be tested ND1601
- Methods refactored should be tested ND1602
- Assemblies and Namespaces should be tested ND1603
- Types almost 100% tested should be 100% tested ND1604
- Namespaces almost 100% tested should be 100% tested ND1605
- Types that used to be 100% covered by tests should still be 100% covered ND1606
- Types tagged with FullCoveredAttribute should be 100% covered ND1607
- Types 100% covered should be tagged with FullCoveredAttribute ND1608
- Methods should have a low C.R.A.P score ND1609
- Complex Methods should be 100% tested ND1610
- Test methods should assert something ND1611
- Test Methods
- Methods directly called by test Methods
- Methods directly and indirectly called by test Methods