dotCover 2020.1 Help

Runtime Coverage Filters

Control+Alt+K F

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

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 shows them neither in the Coverage Results Browser window nor in the Unit Test Coverage window .

Viewing and modifying runtime filters

There are two scopes for coverage filters:

  • All Solutions - global filters that apply to all solutions in your computer.

  • Current Solution - per-solution filters that apply to the current solution. You can share these filters with your team; see Sharing coverage filters for details.

You can view and edit coverage filters in the Coverage Filters dialog. To open this dialog, do one of the following:

  • In Visual Studio, press Control+Alt+K F or choose ReSharper | Cover | Edit Coverage Filters... from the main menu

  • In dotCover standalone application, press Control+Alt+K F or choose File | Edit Coverage Filters... in the menu.

When you open this dialog, you can see filters in both scopes. If no solution is opened, the dialog shows only global filters.

By default, dotCover provides two global filters for excluding code items by the ExcludeFromCodeCoverageAttribute and GeneratedCodeAttribute attributes. If necessary, you can enable/disable, modify or remove it.

View and modify current runtime coverage filters

  1. Open the Coverage Filters dialog.

  2. Use the Group by selector to change the grouping of filters - by scope or by kind.

  3. To enable or disable a filter, use the checkbox next to it.

  4. To remove a filter, select it in the list and click Delete

  5. To edit a filter, select it in the list and click Edit. In the Edit Coverage Filter dialog that appears, make necessary changes as described for adding a new filter below.

  6. Click Save to save and apply your modifications, if any.

Adding runtime filters

Add a runtime coverage filter

  1. In the Coverage Filters dialog, click Add filter.

  2. In the Add Coverage Filter dialog that appears, choose the filter rule:

    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.

    • Analyze code in : Include the specified code item into code coverage analysis and exclude all other code items.

    • Do not analyze code in : Exclude the specified code item from code coverage analysis.

    • Do not analyze code marked with attributes : Exclude code items with the specified attribute from code coverage analysis.

  3. If you have chosen the Analyze code in or Do not analyze code in option, specify an assembly, a class, and/or a method to be included or excluded in the coverage analysis. Code items are filtered independently on one another. For example, if you specify a method and leave asterisks (*) for assembly and class to exclude methods with the specified name from all assemblies and all classes.

    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 that will exclude all test projects from code analysis.

  4. If you have chosen the 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.

  5. In the Apply filter to section, specify the scope of the filter: All solutions or Current solution.

  6. Click OK to finish adding the filter.

  7. In the Coverage Filters dialog, click Save to save 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: 27 May 2020