dotCover 2021.2 Help

Runtime coverage filters

Control+Alt+K F

In Visual Studio:
ReSharper | Cover | Edit Coverage Filters...

In dotCover standalone application:
File | Edit Coverage Filters...

dotCover applies runtime filters during a coverage session. Use these filters to exclude unnecessary code from analysis and reduce coverage session time. You can set the runtime filters for a specific namespace, project, type, type member, or attribute.

As filters are applied in runtime, dotCover does not include the filtered items into the coverage snapshot and does not show them in the Coverage Results Browser window or in the Unit Test Coverage window.

Adding runtime filters

Add a runtime coverage filter

  1. Open the filter settings page in the ReSharper settings: dotCover | Filtering.

  2. In Runtime coverage filters, click Add filter Add ... next to the required filter rule:

    • Analyze code only in: Specify an assembly, a class, and/or a method to be included in the coverage analysis. All other code items will be excluded. Code items are filtered independently on one another. For example, you can specify a method and leave asterisks * for assembly and class to include only methods with the specified name from all assemblies and all classes.

    • Do not analyze code in: Specify an assembly, a class, and/or a method to be excluded from the coverage analysis. Code items are filtered independently on one another.

    • Do not analyze code marked with attributes: Specify the fully qualified attribute class name that will be used to exclude symbols from the coverage analysis. For example, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute or *.ExcludeFromCodeCoverageAttribute.

    You can use asterisk wildcards when specifying code item names in a filter: * (asterisk) represents zero or more characters.
    For example, you can use the *.Tests wildcard in Do not analyze code in to exclude all test projects from code analysis.

  3. Click Save to save the filter settings and apply your modifications.

Sharing runtime coverage filters

Solution-wide filters are saved in the Solution team-shared settings layer and, therefore, can be shared within other developers who work on this solution.

In fact, all you need to do to share solution-wide filters is to put the [SolutionName].sln.DotSettings file in your solution folder under a version control system (VCS). As soon as other team members get this file from VCS the filters will be applied on their computers as well.

Note that other JetBrains products that integrate into Visual Studio may store their solution-wide team-shared settings in the same file. Therefore, if you put this file under VCS, bear in mind that other product's settings may be shared as well. For more information, see Manage and share dotCover settings.

Excluding system and non-solution assemblies from application coverage analysis

When performing coverage analysis of applications, you have additional filters for non-solution and system assemblies in the Filtering options:

  • (Recommended) If you are going to analyze coverage only for assemblies in your solution, select both Exclude system assemblies and Exclude non-solution assemblies. This will make coverage analysis faster.

  • If you are going to analyze coverage for assemblies from several solutions at once, clear Exclude non-solution assemblies.

  • If, for some reason, you want to analyze coverage in system assemblies, clear Exclude system assemblies.

Last modified: 19 August 2021