Test Methods

Code Query Code Coverage

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.

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>

Code Coverage: all 15 items