Skip to content

Commit 371112c

Browse files
committed
update README.md, add filter documentation
1 parent 9ed0864 commit 371112c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,34 @@ You can ignore a method or an entire class from code coverage by creating and ap
8787
Coverlet just uses the type name, so the attributes can be created under any namespace of your choosing.
8888

8989
#### Source Files
90-
You can also ignore specific source files from code coverage using the `Exclude` property
90+
You can also ignore specific source files from code coverage using the `ExcludeByFile` property
9191
- Use single or multiple paths (separate by comma)
9292
- Use absolute or relative paths (relative to the project directory)
9393
- Use file path or directory path with globbing (e.g `dir1/*.cs`)
9494

9595
```bash
96-
dotnet test /p:CollectCoverage=true /p:Exclude=\"../dir1/class1.cs,../dir2/*.cs,../dir3/**/*.cs,\"
96+
dotnet test /p:CollectCoverage=true /p:ExcludeByFile=\"../dir1/class1.cs,../dir2/*.cs,../dir3/**/*.cs,\"
9797
```
9898

99+
#### Filters
100+
Coverlet gives the ability to have fine grained control over what gets excluded using "filter expressions".
101+
102+
Syntax: `/p:Exclude=[Assembly-Filter]Type-Filter`
103+
104+
Examples
105+
- `/p:Exclude="[*]*"` => Excludes all types in all assemblies (nothing is instrumented)
106+
- `/p:Exclude="[coverlet.*]Coverlet.Core.Coverage"` => Excludes the Coverage class in the `Coverlet.Core` namespace belonging to any assembly that matches `coverlet.*` (e.g `coverlet.core`)
107+
- `/p:Exclude="[*]Coverlet.Core.Instrumentation.*"` => Excludes all types belonging to `Coverlet.Core.Instrumentation` namespace in any assembly
108+
109+
```bash
110+
dotnet test /p:CollectCoverage=true /p:Exclude="[coverlet.*]Coverlet.Core.Coverage"
111+
```
112+
113+
You can specify multiple fiter expressions by separting them with a comma (`,`).
114+
99115
## Roadmap
100116

101-
* Filter modules to be instrumented
117+
* Merging outputs (multiple test projects, one coverage result)
102118
* Support for more output formats (e.g. JaCoCo)
103119
* Console runner (removes the need for requiring a NuGet package)
104120

0 commit comments

Comments
 (0)