Test Methods
Lists test methods: methods tagged with a test attribute of a supported test framework (xUnit, NUnit, MSTest, TUnit…) declared in test assemblies.
Test assemblies (assemblies referencing a test framework) belong to the TestCode view, disjoint from Application: rules don't report issues on test code (except Test methods should assert something), while dependencies between test and application code remain available, as in this query.
Test assemblies (assemblies referencing a test framework) belong to the TestCode view, disjoint from Application: rules don't report issues on test code (except Test methods should assert something), while dependencies between test and application code remain available, as in this query.
CQLinq source
This code query 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>Test Methods</Name>
from m in TestCode.Methods
where m.IsTestMethod
select new { m, m.ParentType, m.NbLinesOfCode }
//<Desc>
// Lists test methods: methods tagged with a test attribute of a supported
// test framework (xUnit, NUnit, MSTest, TUnit…) declared in test assemblies.
//
// Test assemblies (assemblies referencing a test framework) belong to the
// **TestCode** view, disjoint from *Application*: rules don't report issues
// on test code (except *Test methods should assert something*), while
// dependencies between test and application code remain available, as in
// this query.
//</Desc>
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