Restricting coverage by classes/methods

Restricting coverage by classes/methods

Hello! Is there some way to restrict coverage report in a way that TestFixture (class with testcases) with say attribute 'ClassCovered ="MyClass1"' will mark visited lines only within the class being tested? (ClassCovered-MyClass). Example: we have a automated nightly UT run that also provides line coverage. Say all algorithms we use are placed in one assembly (Algorithms). Within the assembly are some calculation classes that use some shared containers. When running all the UTs for calculation that uses those containers - some functionality of the containers is covered by calculation calls. But this coverage is not wanted, because UTs are testing calculation functionality, not the containers. We want a coverage for the class when actually the functionality is being tested (UTs). Only containers UTs should provide coverage for container classes. Splitting algorithms into more assemblies is not a option as we already work with hundreds of different assemblies. Thanks for any advice!


RE: Restricting coverage by classes/methods

There is no current way with NCover to determine what code was covered by which tests.

We are looking into adding this feature in a future release.

Joe Feser


RE: Restricting coverage by classes/methods

Hi again. Is this feature now present in NCover 3.4 ? or already earlier version? Thank you.


RE: Restricting coverage by classes/methods

It's not yet available in NCover. We're currently looking at the features for NCover 4, though, and we'll be sure to include your feedback as part of that process.


RE: Restricting coverage by classes/methods

One of the NCover 3.0 Complete features listed on these pages is 'Pre and post inclusion and exclusion filters on types, methods, source files, and attributes allow targeted analysis of development'. Doesn't that cover custom exclusion of coverage ?


RE: Restricting coverage by classes/methods

We do exclusion based on regular expression at the assembly, type, method, and file level. We also do exclusion based on attributes, but attribute based exclusion only excludes methods, namespaces, and classes marked with the attribute, not methods called by methods marked with an attribute.