You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84-77Lines changed: 84 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ tool for most developers. It is currently in Beta.
20
20
21
21
With the old coverage it was possible for FCC to provide an abstraction over each tool's exclusion / inclusion options. This abstraction does not work for MS code coverage.
22
22
Thus you will find that there are separate configuration options for Ms coverage vs old coverage and options that are common to the two.
23
+
Assembly level exclusions and inclusions can be achieved - see ExcludeAssemblies and IncludeAssemblies.
23
24
Configuration is ( mostly ) determined from Visual Studio options, finecodecoverage-settings.xml files and project msbuild properties. All of these settings are optional.
24
25
For options that have a project scope, these settings form a hierarchy where lower levels override or, for collections, override or merge with the level above. This is described in detail further on.
25
26
@@ -227,101 +228,107 @@ If you are using option 1) then project and global options will only be used whe
227
228
228
229
229
230
#### Options
230
-
```
231
-
*** Common
232
-
CoverageColoursFromFontsAndColours Specify true to use Environment / Fonts and Colors / Text Editor for editor Coverage colouring ( if present).
233
-
Coverage Touched Area / Coverage Not Touched Area / Coverage Partially Touched Area.
234
-
When false colours used are Green, Red and Gold.
231
+
|Option |Description|
232
+
|--|---|
233
+
|**Common**||
234
+
|CoverageColoursFromFontsAndColours|Specify true to use Environment / Fonts and Colors / Text Editor for editor Coverage colouring ( if present). Coverage Touched Area / Coverage Not Touched Area / Coverage Partially Touched Area. When false colours used are Green, Red and Gold.|
235
+
|ShowCoverageInOverviewMargin|Set to false to prevent coverage marks in the overview margin|
236
+
|ShowCoveredInOverviewMargin|Set to false to prevent covered marks in the overview margin|
237
+
|ShowUncoveredInOverviewMargin|Set to false to prevent uncovered marks in the overview margin|
238
+
|ShowPartiallyCoveredInOverviewMargin|Set to false to prevent partially covered marks in the overview margin|
239
+
|ShowToolWindowToolbar|Set to false to hide the toolbar on the tool window. Requires restarting Visual Studio. The toolbar has buttons for viewing the Cobertura xml and the risk hotspots.|
240
+
|FCCSolutionOutputDirectoryName|To have fcc output visible in a sub folder of your solution provide this name|
241
+
|ToolsDirectory|Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.|
242
+
|ThresholdForCyclomaticComplexity| When [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) exceeds this value for a method then the method will be present in the risk hotspots tab. |
243
+
|StickyCoverageTable|Set to true for coverage table to have a sticky thead.|
244
+
|NamespacedClasses|Set to false to show classes in report in short form. Affects grouping.|
245
+
|HideFullyCovered|Set to true to hide classes, namespaces and assemblies that are fully covered.|
246
+
|Hide0Coverage|Set to true to hide classes, namespaces and assemblies that have 0% coverage.|
247
+
|Hide0Coverable|Set to false to show classes, namespaces and assemblies that are not coverable.|
248
+
|Enabled|Specifies whether or not coverage output is enabled|
249
+
|RunWhenTestsFail|By default coverage runs when tests fail. Set to false to prevent this. **Cannot be used in conjunction with RunInParallel**|
250
+
|RunWhenTestsExceed|Specify a value to only run coverage based upon the number of executing tests. **Cannot be used in conjunction with RunInParallel**|
251
+
|RunMsCodeCoverage|Change to IfInRunSettings to only collect with configured runsettings. Yes for runsettings generation.|
252
+
|IncludeTestAssembly|Specifies whether to report code coverage of the test assembly|
253
+
|IncludeReferencedProjects|Set to true to add all directly referenced projects to Include.|
254
+
|IncludeAssemblies|Provide a list of assemblies to include in coverage. The dll name without extension is used for matching.|
255
+
|ExcludeAssemblies| Provide a list of assemblies to exclude from coverage. The dll name without extension is used for matching.|
256
+
|<br>||
257
+
|**OpenCover / Coverlet**||
258
+
|AdjacentBuildOutput|If your tests are dependent upon their path set this to true.|
259
+
|Exclude|Filter expressions to exclude specific modules and types (multiple values)|
260
+
|Include|Filter expressions to include specific modules and types (multiple values)|
261
+
|ExcludeByFile|Glob patterns specifying source files to exclude e.g. **/Migrations/* (multiple values)|
262
+
|ExcludeByAttribute|Attributes to exclude from code coverage (multiple values)|
263
+
|RunInParallel|By default OpenCover / Coverlet tests run and then coverage is performed. Set to true to run coverage immediately|
264
+
|<br>||
265
+
|**Ms code coverage**|Each of below is an array of regexes to be transformed into runsettings elements [see](https://learn.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022#include-or-exclude-assemblies-and-members)|
266
+
|ModulePathsExclude|Exclude - Matches assemblies specified by assembly name or file path.|
267
+
|ModulePathsInclude|Include - Matches assemblies specified by assembly name or file path.|
268
+
|CompanyNamesExclude|Exclude - Matches assemblies by the Company attribute.|
269
+
|CompanyNamesInclude|Include - Matches assemblies by the Company attribute.|
270
+
|PublicKeyTokensExclude|Exclude - Matches signed assemblies by the public key token.|
271
+
|PublicKeyTokensInclude|Include - Matches signed assemblies by the public key token.|
272
+
|SourcesExclude|Exclude - Matches elements by the path name of the source file in which they're defined.|
273
+
|SourcesInclude|Include - Matches elements by the path name of the source file in which they're defined.|
274
+
|AttributesExclude|Exclude - Matches elements that have the specified attribute. Specify the full name of the attribute|
275
+
|AttributesInclude|Include - Matches elements that have the specified attribute. Specify the full name of the attribute|
276
+
|FunctionsExclude|Exclude - Matches procedures, functions, or methods by fully qualified name, including the parameter list.|
277
+
|FunctionsInclude|Include - Matches procedures, functions, or methods by fully qualified name, including the parameter list.|
278
+
|<br>||
279
+
|**Coverlet**||
280
+
|RunSettingsOnly|Specify false for global and project options to be used for coverlet data collector configuration elements when not specified in runsettings|
281
+
|CoverletCollectorDirectoryPath|Specify path to directory containing coverlet collector files if you need functionality that the FCC version does not provide.|
282
+
|CoverletConsoleLocal|Specify true to use your own dotnet tools local install of coverlet console.|
283
+
|CoverletConsoleCustomPath|Specify path to coverlet console exe if you need functionality that the FCC version does not provide.|
284
+
|CoverletConsoleGlobal|Specify true to use your own dotnet tools global install of coverlet console.|
285
+
|**The "CoverletConsole" settings have precedence Local / CustomPath / Global.**||
286
+
|<br>||
287
+
|**OpenCover**||
288
+
|OpenCoverCustomPath|Specify path to open cover exe if you need functionality that the FCC version does not provide.|
289
+
|ThresholdForNPathComplexity|When [npath complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) exceeds this value for a method then the method will be present in the risk hotspots tab.|
290
+
|ThresholdForCrapScore|When [crap score](https://testing.googleblog.com/2011/02/this-code-is-crap.html) exceeds this value for a method then the method will be present in the risk hotspots tab.|
291
+
235
292
236
-
ShowCoverageInOverviewMargin Set to false to prevent coverage marks in the overview margin
237
-
ShowCoveredInOverviewMargin Set to false to prevent covered marks in the overview margin
238
-
ShowUncoveredInOverviewMargin Set to false to prevent uncovered marks in the overview margin
239
-
ShowPartiallyCoveredInOverviewMargin Set to false to prevent partially covered marks in the overview margin
293
+
## Exclusions and inclusions
294
+
You probably want to set IncludeReferencedProjects to true. This will ensure that you do not get coverage for testing frameworks - only your code.
240
295
241
-
ShowToolWindowToolbar Set to false to hide the toolbar on the tool window. Requires restarting Visual Studio. The toolbar has buttons for viewing
242
-
the Cobertura xml and the risk hotspots.
296
+
Coverlet and OpenCover use filter expressions.
297
+
Filter expressions
243
298
244
-
FCCSolutionOutputDirectoryName To have fcc output visible in a sub folder of your solution provide this name
299
+
Wildcards
245
300
246
-
ToolsDirectory Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.
301
+
\* => matches zero or more characters
302
+
303
+
Examples
247
304
248
-
ThresholdForCyclomaticComplexity When [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) exceeds this value for a method then the method will be present in the risk hotspots tab.
305
+
[\*]* => All types in all assemblies.
249
306
250
-
StickyCoverageTable Set to true for coverage table to have a sticky thead.
251
-
NamespacedClasses Set to false to show classes in report in short form. Affects grouping.
252
-
HideFullyCovered Set to true to hide classes, namespaces and assemblies that are fully covered.
253
-
Hide0Coverage Set to true to hide classes, namespaces and assemblies that have 0% coverage.
254
-
Hide0Coverable Set to false to show classes, namespaces and assemblies that are not coverable.
307
+
[coverlet\.\*]Coverlet.Core.Coverage => The Coverage class in the Coverlet.Core namespace belonging to any assembly that matches coverlet.* (e.g coverlet.core)
255
308
256
-
Enabled Specifies whether or not coverage output is enabled
257
-
RunWhenTestsFail By default coverage runs when tests fail. Set to false to prevent this. **Cannot be used in conjunction with RunInParallel**
258
-
RunWhenTestsExceed Specify a value to only run coverage based upon the number of executing tests. **Cannot be used in conjunction with RunInParallel**
259
-
RunMsCodeCoverage Change to IfInRunSettings to only collect with configured runsettings. Yes for runsettings generation.
309
+
[\*\]Coverlet.Core.Instrumentation.* => All types belonging to Coverlet.Core.Instrumentation namespace in any assembly
260
310
261
-
IncludeTestAssembly Specifies whether to report code coverage of the test assembly
262
-
IncludeReferencedProjects Set to true to add all referenced projects to Include.
311
+
[coverlet\.\*.tests]* => All types in any assembly starting with coverlet. and ending with .tests
263
312
264
-
*** OpenCover / Coverlet
265
-
AdjacentBuildOutput If your tests are dependent upon their path set this to true.
313
+
Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.
266
314
267
-
Exclude Filter expressions to exclude specific modules and types (multiple values)
268
-
Include Filter expressions to include specific modules and types (multiple values)
269
-
ExcludeByFile Glob patterns specifying source files to exclude e.g. **/Migrations/* (multiple values)
270
-
ExcludeByAttribute Attributes to exclude from code coverage (multiple values)
271
-
RunInParallel By default OpenCover / Coverlet tests run and then coverage is performed. Set to true to run coverage immediately
315
+
Ms code coverage uses [regexes](https://learn.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022#regular-expressions).
316
+
You can include or exclude assemblies or specific types and members from code coverage analysis. If the Include section is empty or omitted, then all assemblies that are loaded and have associated PDB files are included. If an assembly or member matches a clause in the Exclude section, then it is excluded from code coverage. The Exclude section takes precedence over the Include section: if an assembly is listed in both Include and Exclude, it will not be included in code coverage.
272
317
273
-
Filter expressions
274
-
Wildcards
275
-
* => matches zero or more characters
276
-
277
-
Examples
278
-
[*]* => All types in all assemblies (nothing is instrumented)
279
-
[coverlet.*]Coverlet.Core.Coverage => The Coverage class in the Coverlet.Core namespace belonging to any assembly that matches coverlet.* (e.g coverlet.core)
280
-
[*]Coverlet.Core.Instrumentation.* => All types belonging to Coverlet.Core.Instrumentation namespace in any assembly
281
-
[coverlet.*.tests]* => All types in any assembly starting with coverlet. and ending with .tests
282
318
319
+
You can ignore a method or an entire class from code coverage by applying the [ExcludeFromCodeCoverage] attribute present in the System.Diagnostics.CodeAnalysis namespace.
283
320
284
-
Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.
321
+
For .Net Framework this attribute cannot be applied at the assembly level. See FCCExcludeFromCodeCoverage above for similar functinality.
285
322
286
-
You can ignore a method or an entire class from code coverage by creating and applying the [ExcludeFromCodeCoverage] attribute present in the System.Diagnostics.CodeAnalysis namespace.
287
-
You can also ignore additional attributes by adding to the 'ExcludeByAttributes' list (short name or full name supported) e.g. :
288
-
[GeneratedCode] => Present in System.CodeDom.Compiler namespace
289
-
[MyCustomExcludeFromCodeCoverage] => Any custom attribute that you may define
323
+
You can also ignore additional attributes by adding to the 'ExcludeByAttributes' list for Coverlet/OpenCover (short name or full name supported)
290
324
291
-
*** MS Code Coverage each multiple regexes to be transformed into runsettings elements
292
-
ModulePathsExclude
293
-
ModulePathsInclude
294
-
CompanyNamesExclude
295
-
CompanyNamesInclude
296
-
PublicKeyTokensExclude
297
-
PublicKeyTokensInclude
298
-
SourcesExclude
299
-
SourcesInclude
300
-
AttributesExclude
301
-
AttributesInclude
302
-
FunctionsExclude
303
-
FunctionsInclude
304
-
305
-
*** Coverlet
306
-
RunSettingsOnly Specify false for global and project options to be used for coverlet data collector configuration elements when not specified in runsettings
307
-
CoverletCollectorDirectoryPath Specify path to directory containing coverlet collector files if you need functionality that the FCC version does not provide.
308
-
CoverletConsoleLocal Specify true to use your own dotnet tools local install of coverlet console.
309
-
CoverletConsoleCustomPath Specify path to coverlet console exe if you need functionality that the FCC version does not provide.
310
-
CoverletConsoleGlobal Specify true to use your own dotnet tools global install of coverlet console.
311
-
312
-
The "CoverletConsole" settings have precedence Local / CustomPath / Global.
313
-
314
-
*** OpenCover
315
-
OpenCoverCustomPath Specify path to open cover exe if you need functionality that the FCC version does not provide.
316
-
ThresholdForNPathComplexity When [npath complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) exceeds this value for a method then the method will be present in the risk hotspots tab. OpenCover only.
317
-
ThresholdForCrapScore When [crap score](https://testing.googleblog.com/2011/02/this-code-is-crap.html) exceeds this value for a method then the method will be present in the risk hotspots tab. OpenCover only.
325
+
e.g. :
318
326
327
+
[GeneratedCode] => Present in System.CodeDom.Compiler namespace
319
328
320
-
321
-
```
322
-
## Exclusions and inclusions
323
-
You probably want to set IncludeReferencedProjects to true. This will ensure that you do not get coverage for testing frameworks - only your code.
329
+
[MyCustomExcludeFromCodeCoverage] => Any custom attribute that you may define
324
330
331
+
or for ms code coverage - AttributesExclude
325
332
326
333
## FCC Output
327
334
FCC outputs, by default, inside each test project's Debug folder.
0 commit comments