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
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.
179
179
180
+
You can also ignore additional attributes by using the `ExcludeByAttribute` property (short name or full name supported):
Coverlet goes a step in the other direction by also letting you explicitly set what can be included using the `--include` option.
218
+
Coverlet goes a step in the other direction by also letting you explicitly set what can be included using the `--include` option.
213
219
214
220
Examples
215
221
- `--include "[*]*"` => Includes all types in all assemblies (everything is instrumented)
@@ -225,7 +231,7 @@ In this mode, Coverlet doesn't require any additional setup other than including
225
231
If a property takes multiple comma-separated values please note that [you will have to add escaped quotes around the string](https://github.com/Microsoft/msbuild/issues/2999#issuecomment-366078677) like this: `/p:Exclude=\"[coverlet.*]*,[*]Coverlet.Core*\"`, `/p:Include=\"[coverlet.*]*,[*]Coverlet.Core*\"`, or `/p:CoverletOutputFormat=\"json,opencover\"`.
226
232
227
233
##### Note for Powershell / VSTS users
228
-
To exclude or include multiple assemblies when using Powershell scripts or creating a .yaml file for a VSTS build ```%2c``` should be used as a separator. Msbuild will translate this symbol to ```,```.
234
+
To exclude or include multiple assemblies when using Powershell scripts or creating a .yaml file for a VSTS build ```%2c``` should be used as a separator. Msbuild will translate this symbol to ```,```.
229
235
230
236
```/p:Exclude="[*]*Examples?%2c[*]*Startup"```
231
237
@@ -306,6 +312,12 @@ You can specify multiple values for `ThresholdType` by separating them with comm
306
312
307
313
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.
308
314
315
+
You can also ignore additional attributes by using the `ExcludeByAttribute` property (short name or full name supported):
316
+
317
+
```bash
318
+
dotnet test /p:CollectCoverage=true /p:ExcludeByAttribute="Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute"
319
+
```
320
+
309
321
#### Source Files
310
322
You can also ignore specific source files from code coverage using the `ExcludeByFile` property
311
323
- Use single or multiple paths (separate by comma)
@@ -316,7 +328,7 @@ You can also ignore specific source files from code coverage using the `ExcludeB
316
328
dotnet test /p:CollectCoverage=true /p:ExcludeByFile=\"../dir1/class1.cs,../dir2/*.cs,../dir3/**/*.cs,\"
317
329
```
318
330
319
-
##### Filters
331
+
##### Filters
320
332
Coverlet gives the ability to have fine grained control over what gets excluded using "filter expressions".
321
333
322
334
Syntax: `/p:Exclude=[Assembly-Filter]Type-Filter`
@@ -336,7 +348,7 @@ Examples
336
348
dotnet test /p:CollectCoverage=true /p:Exclude="[coverlet.*]Coverlet.Core.Coverage"
337
349
```
338
350
339
-
Coverlet goes a step in the other direction by also letting you explicitly set what can be included using the `Include` property.
351
+
Coverlet goes a step in the other direction by also letting you explicitly set what can be included using the `Include` property.
340
352
341
353
Examples
342
354
- `/p:Include="[*]*"` => Includes all types in all assemblies (everything is instrumented)
0 commit comments