Skip to content

Commit 2e59183

Browse files
committed
update README.md
1 parent 748e071 commit 2e59183

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Options:
6565
--threshold Exits with error if the coverage % is below value.
6666
--threshold-type Coverage type to apply the threshold to.
6767
--exclude Filter expressions to exclude specific modules and types.
68+
--include Filter expressions to include specific modules and types.
6869
--exclude-by-file Glob patterns specifying source files to exclude.
6970
```
7071
@@ -173,7 +174,14 @@ Examples
173174
coverlet <ASSEMBLY> --target <TARGET> --targetargs <TARGETARGS> --exclude "[coverlet.*]Coverlet.Core.Coverage"
174175
```
175176
176-
You can specify the `--exclude` option multiple times to allow for multiple filter expressions.
177+
Coverlet goes a step in the other direction by also letting you explicitly set what can be included using the `--include` option.
178+
179+
Examples
180+
- `--include "[*]*"` => INcludes all types in all assemblies (nothing is instrumented)
181+
- `--include "[coverlet.*]Coverlet.Core.Coverage"` => Includes the Coverage class in the `Coverlet.Core` namespace belonging to any assembly that matches `coverlet.*` (e.g `coverlet.core`)
182+
- `--include "[coverlet.*.tests?]*"` => Includes all types in any assembly starting with `coverlet.` and ending with `.test` or `.tests` (the `?` makes the `s` optional)
183+
184+
Both `--exclude` and `--include` options can be used together but `--exclude` takes precedence. You can specify the `--exclude` and `--include` options multiple times to allow for multiple filter expressions.
177185
178186
### MSBuild
179187
@@ -270,9 +278,16 @@ Examples
270278
dotnet test /p:CollectCoverage=true /p:Exclude="[coverlet.*]Coverlet.Core.Coverage"
271279
```
272280
281+
Coverlet goes a step in the other direction by also letting you explicitly set what can be included using the `Include` property.
282+
283+
Examples
284+
- `/p:Include="[*]*"` => INcludes all types in all assemblies (nothing is instrumented)
285+
- `/p:Include="[coverlet.*]Coverlet.Core.Coverage"` => Includes the Coverage class in the `Coverlet.Core` namespace belonging to any assembly that matches `coverlet.*` (e.g `coverlet.core`)
286+
- `/p:Include="[coverlet.*.tests?]*"` => Includes all types in any assembly starting with `coverlet.` and ending with `.test` or `.tests` (the `?` makes the `s` optional)
287+
288+
Both `Exclude` and `Include` properties can be used together but `Exclude` takes precedence.
273289
274-
You can specify multiple filter expressions by separting them with a comma (`,`). If you specify multiple filters, then [you'll have to escape the surrounding quotes](https://github.com/Microsoft/msbuild/issues/2999#issuecomment-366078677) like this:
275-
`/p:Exclude=\"[coverlet.*]*,[*]Coverlet.Core*\"`.
290+
You can specify multiple filter expressions by separting them with a comma (`,`). If you specify multiple filters, then [you'll have to escape the surrounding quotes](https://github.com/Microsoft/msbuild/issues/2999#issuecomment-366078677) like this: `/p:Exclude=\"[coverlet.*]*,[*]Coverlet.Core*\"` or `/p:Include=\"[coverlet.*]*,[*]Coverlet.Core*\"`.
276291
277292
### Cake Addin
278293
If you're using [Cake Build](https://cakebuild.net) for your build script you can use the [Cake.Coverlet](https://github.com/Romanx/Cake.Coverlet) addin to provide you extensions to dotnet test for passing coverlet arguments in a strongly typed manner.

0 commit comments

Comments
 (0)