Skip to content

Commit 158aede

Browse files
committed
update readme
1 parent e4a5339 commit 158aede

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

README.md

+35-26
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ or download from [releases](https://github.com/FortuneN/FineCodeCoverage/release
1313

1414
For .Net
1515

16-
FCC supports the new [Microsoft.Testing.Platform]( https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-intro).
16+
FCC supports the new [Microsoft.Testing.Platform](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-intro).
1717
FCC does not support the associated testing platform server mode for when using microsoft as a coverage provider.
1818
You can disable this feature - "Options / Environment / Preview Features / Use testing platform server mode"
19-
but it is not necessary as FCC adds a global msbuild property, DisableTestingPlatformServerCapability true, that removes
19+
but it is not necessary as FCC adds a global msbuild property, DisableTestingPlatformServerCapability true, that removes
2020
the project capability. ([see Microsoft.Testing.Platform.MSBuild.targets](https://github.com/microsoft/testfx/blob/d141931b99fad0617d8435ce321fca0c45c9eb94/src/Platform/Microsoft.Testing.Platform.MSBuild/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets#L10)).
2121

2222
When not using Microsoft.TestingPlatform you have added test adapters through nuget packages. For instance, the NUnit Test Adapter extension is not sufficient.
@@ -111,7 +111,7 @@ The old coverage was based upon every test. Ms code coverage is coverage from th
111111

112112
Ms code coverage requires a [runsettings](https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022) file that is configured appropriately for
113113
code coverage. This requires that you have the ms code coverage package and have pointed to it with the TestAdaptersPaths element as well as specifying the ms data collector. [Exclusions and inclusions](https://docs.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022#include-or-exclude-assemblies-and-members)
114-
are also specified in the runsettings. I don't think that the documentation is clear enough on how this works so you may want to look at [this issue](https://github.com/microsoft/vstest/issues/3462).
114+
are also specified in the runsettings.
115115

116116
FCC does not require you to do this. If you do not provide a runsettings and RunMsCodeCoverage is Yes then FCC will generate one and write the necessary entry in the project file.
117117
Note that having a test project file open in visual studio whilst running tests may result in a conflict warning when FCC removes the entry at the end of the test.
@@ -140,9 +140,12 @@ It is also possible to use your own runsettings file and have FCC add to it and
140140

141141
## Run settings defaults and merging
142142

143-
Ms code coverage does provide a default Configuration / CodeCoverage element if not provided. It will also add some default exclusions if not present or merge them in unless you add the attribute mergeDefaults='false'.
144-
For instance it Attributes exclude ExcludeFromCodeCoverageAttribute.
145-
If you are interested see ...\AppData\Local\FineCodeCoverage\msCodeCoverage_version\_\build\netstandard1.0\Microsoft.VisualStudio.TraceDataCollector.dll and the DynamicCoverageDataCollector.
143+
Ms code coverage does provide a default Configuration / CodeCoverage element if not provided. It will also add some default exclusions for ModulePaths, Attributes, Sources, Functions, and PublicKeyTokens if not present in inclusions or exclusions unless you add the attribute mergeDefaults='false'.
144+
For instance for Attributes it will exclude ExcludeFromCodeCoverageAttribute.
145+
146+
If you are interested in using DotPeek or Reflector against the Microsoft source code within
147+
...\AppData\Local\FineCodeCoverage\msCodeCoverage_version\_\build\netstandard2.0\ there is the Microsoft.VisualStudio.TraceDataCollector.dll.
148+
see `DynamicCoverageDataCollector.OnInitialize` for the default configuration logic. The default config is in the resources of Microsoft.CodeCoverage.Core.
146149

147150
## Problems with ms code coverage
148151

@@ -347,7 +350,7 @@ If you are using option 1) then project and global options will only be used whe
347350
| DisabledNoCoverage | Set to false for VS Option Enabled=false to not disable coverage |
348351
| RunWhenTestsFail | By default coverage runs when tests fail. Set to false to prevent this. **Cannot be used in conjunction with RunInParallel** |
349352
| RunWhenTestsExceed | Specify a value to only run coverage based upon the number of executing tests. **Cannot be used in conjunction with RunInParallel** |
350-
| RunMsCodeCoverage | Change to IfInRunSettings to only collect with configured runsettings. Yes (default) for runsettings generation. No to use Coverlet or OpenCover. |
353+
| RunMsCodeCoverage | Change to IfInRunSettings to only collect with configured runsettings. Yes (default) for runsettings generation. No to use Coverlet or OpenCover. |
351354
| IncludeTestAssembly | Specifies whether to report code coverage of the test assembly |
352355
| IncludeReferencedProjects | Set to true to add all directly referenced projects to Include. |
353356
| IncludeAssemblies | Provide a list of assemblies to include in coverage. The dll name without extension is used for matching. |
@@ -393,28 +396,34 @@ If you are using option 1) then project and global options will only be used whe
393396

394397
## Exclusions and inclusions
395398

396-
You probably want to set IncludeReferencedProjects to true. This will ensure that you do not get coverage for testing frameworks - only your code.
397-
398399
Coverlet and OpenCover use filter expressions.
399-
Filter expressions
400-
401-
Wildcards
402-
403-
\* => matches zero or more characters
404-
Examples
405400

406-
[\*]\* => All types in all assemblies.
407-
408-
[coverlet\.\*]Coverlet.Core.Coverage => The Coverage class in the Coverlet.Core namespace belonging to any assembly that matches coverlet.\* (e.g coverlet.core)
401+
Filter expressions
409402

410-
[\*\]Coverlet.Core.Instrumentation.\* => All types belonging to Coverlet.Core.Instrumentation namespace in any assembly
403+
> Wildcards
404+
>
405+
> \* => matches zero or more characters
406+
>
407+
> Examples
408+
>
409+
> [\*]\* => All types in all assemblies.
410+
>
411+
> [coverlet\.\*]Coverlet.Core.Coverage => The Coverage class in the Coverlet.Core namespace belonging to any assembly that matches coverlet.\* (e.g coverlet.core)
412+
>
413+
> [\*\]Coverlet.Core.Instrumentation.\* => All types belonging to Coverlet.Core.Instrumentation namespace in any assembly
414+
>
415+
> [coverlet\.\*.tests]\* => All types in any assembly starting with coverlet. and ending with .tests
416+
>
417+
> Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.
411418
412-
[coverlet\.\*.tests]\* => All types in any assembly starting with coverlet. and ending with .tests
419+
Ms code coverage uses [regexes](https://learn.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022#regular-expressions).
413420

414-
Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.
421+
> 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.
415422
416-
Ms code coverage uses [regexes](https://learn.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022#regular-expressions).
417-
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.
423+
Just remember that as soon as there is an include for an assembly all other assemblies that you require coverage for will also need to be included. ( [internals](https://github.com/FortuneN/FineCodeCoverage/issues/489) )
424+
If there are no includes then all assemblies will be included unless explicitly excluded.
425+
Hence when IncludeTestAssembly is true FCC only explicitly includes it when there are other includes specified.
426+
**You may want to set IncludeReferencedProjects to true. This will ensure that you do not get coverage for testing frameworks - only your code.**
418427

419428
You can ignore a method or an entire class from code coverage by applying the [ExcludeFromCodeCoverage] attribute present in the System.Diagnostics.CodeAnalysis namespace.
420429

@@ -447,19 +456,19 @@ if you want to contribute to this project.
447456
For cloning and building this project yourself, make sure
448457
to install the [Extensibility Essentials](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ExtensibilityEssentials2022)
449458
extension for Visual Studio which enables some features
450-
used by this project.
459+
used by this project.
451460

452461
## License
453462

454463
[Apache 2.0](LICENSE)
455464

456-
## Credits
465+
## Credits
457466

458467
[Coverlet](https://github.com/coverlet-coverage/coverlet)
459468

460469
[OpenCover](https://github.com/OpenCover/opencover)
461470

462-
[ReportGenerator](https://github.com/danielpalme/ReportGenerator)
471+
[ReportGenerator](https://github.com/danielpalme/ReportGenerator)
463472

464473
## Please support the project
465474

0 commit comments

Comments
 (0)