Skip to content

Commit 2228f44

Browse files
committed
Make ms code coverage the default
1 parent 97eeb80 commit 2228f44

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

FineCodeCoverageTests/AppOptionsProvider_Tests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public void Should_Not_Default_Any_Other_AppOptions_Properties()
200200
nameof(IAppOptions.ThresholdForCrapScore),
201201
nameof(IAppOptions.ThresholdForNPathComplexity),
202202
nameof(IAppOptions.ThresholdForCyclomaticComplexity),
203+
nameof(IAppOptions.RunMsCodeCoverage),
203204
nameof(IAppOptions.NamespacedClasses),
204205
nameof(IAppOptions.ShowCoverageInOverviewMargin),
205206
nameof(IAppOptions.ShowCoveredInOverviewMargin),

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ When not using Microsoft.TestingPlatform you have added test adapters through nu
2727

2828
Fine Code Coverage provides code coverage using one of 3 different coverage tools. In previous releases there were two coverage tools being utilised, OpenCover and Coverlet that will be referred to as 'old coverage'.
2929
Microsoft now provides a free coverage solution that you can choose to use by setting the Visual Studio Fine Code Coverage enumeration option RunMsCodeCoverage. This will probably be the preferred coverage
30-
tool for most developers. It is currently in Beta.
30+
tool for most developers.
3131

3232
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.
3333
Thus you will find that there are separate configuration options for Ms coverage vs old coverage and options that are common to the two.
@@ -109,8 +109,6 @@ The old coverage was based upon every test. Ms code coverage is coverage from th
109109

110110
## How to utilize MS Code Coverage with FCC ?
111111

112-
Firstly you need to change the RunMsCodeCoverage option from No.
113-
114112
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
115113
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)
116114
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).
@@ -349,7 +347,7 @@ If you are using option 1) then project and global options will only be used whe
349347
| DisabledNoCoverage | Set to false for VS Option Enabled=false to not disable coverage |
350348
| RunWhenTestsFail | By default coverage runs when tests fail. Set to false to prevent this. **Cannot be used in conjunction with RunInParallel** |
351349
| RunWhenTestsExceed | Specify a value to only run coverage based upon the number of executing tests. **Cannot be used in conjunction with RunInParallel** |
352-
| RunMsCodeCoverage | Change to IfInRunSettings to only collect with configured runsettings. Yes for runsettings generation. |
350+
| RunMsCodeCoverage | Change to IfInRunSettings to only collect with configured runsettings. Yes (default) for runsettings generation. No to use Coverlet or OpenCover. |
353351
| IncludeTestAssembly | Specifies whether to report code coverage of the test assembly |
354352
| IncludeReferencedProjects | Set to true to add all directly referenced projects to Include. |
355353
| IncludeAssemblies | Provide a list of assemblies to include in coverage. The dll name without extension is used for matching. |

SharedProject/Core/MsTestPlatform/CodeCoverage/MsCodeCoverageRunSettingsService.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,7 @@ public void Initialize(string appDataFolder, IFCCEngine fccEngine, CancellationT
121121
public async Task<MsCodeCoverageCollectionStatus> IsCollectingAsync(ITestOperation testOperation)
122122
{
123123
await InitializeIsCollectingAsync(testOperation);
124-
if( runMsCodeCoverage == RunMsCodeCoverage.No)
125-
{
126-
logger.Log($"See option {nameof(IAppOptions.RunMsCodeCoverage)} for a better ( Beta ) experience. {FCCGithub.Readme}");
127-
reportGeneratorUtil.LogCoverageProcess($"See option {nameof(IAppOptions.RunMsCodeCoverage)} for a better ( Beta ) experience. View readme.");
128-
}
129-
else
124+
if( runMsCodeCoverage != RunMsCodeCoverage.No)
130125
{
131126
await TrySetUpForCollectionAsync(testOperation.SolutionDirectory);
132127
}

SharedProject/Options/AppOptionsPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private static IAppOptionsStorageProvider GetAppOptionsStorageProvider()
7575
public bool DisabledNoCoverage { get; set; }
7676

7777
[Category(commonRunCategory)]
78-
[Description("Specifies whether or not the ms code coverage is used (BETA). No, IfInRunSettings, Yes")]
78+
[Description("Specifies whether or not the ms code coverage is used. No, IfInRunSettings, Yes ( default )")]
7979
//[DisplayName("Run Ms Code Coverage)")]
8080
public RunMsCodeCoverage RunMsCodeCoverage { get; set; }
8181

SharedProject/Options/AppOptionsProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ private void AddDefaults(IAppOptions appOptions)
6060
appOptions.ThresholdForCrapScore = 15;
6161
appOptions.ThresholdForNPathComplexity = 200;
6262
appOptions.ThresholdForCyclomaticComplexity = 30;
63+
appOptions.RunMsCodeCoverage = RunMsCodeCoverage.Yes;
6364
appOptions.RunSettingsOnly = true;
6465
appOptions.RunWhenTestsFail = true;
6566
appOptions.ExcludeByAttribute = new[] { "GeneratedCode" };

0 commit comments

Comments
 (0)