Skip to content

Commit 49dd868

Browse files
Switch to coverlet
Switch to coverlet for code coverage from OpenCover.
1 parent 24f8449 commit 49dd868

File tree

3 files changed

+14
-31
lines changed

3 files changed

+14
-31
lines changed

build/common.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@
1111
<DebugType>portable</DebugType>
1212
</PropertyGroup>
1313

14+
<PropertyGroup>
15+
<CollectCoverage>true</CollectCoverage>
16+
<CoverletOutput>$(OutputPath)/</CoverletOutput>
17+
<CoverletOutputFormat>cobertura,json</CoverletOutputFormat>
18+
<Exclude>[Mvc.Client*]*,[xunit.*]*</Exclude>
19+
<ExcludeByAttribute>System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>
20+
</PropertyGroup>
21+
1422
</Project>

build/dependencies.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
<PropertyGroup Label="Package Versions">
44
<AspNetCoreVersion>3.0.0-preview6.19307.2</AspNetCoreVersion>
5+
<CoverletVersion>2.6.2</CoverletVersion>
56
<DotNetTestSdkVersion>16.2.0-preview-20190606-02</DotNetTestSdkVersion>
67
<GoogleProviderVersion>3.0.0-preview6.19307.2</GoogleProviderVersion>
78
<JetBrainsVersion>2019.1.1</JetBrainsVersion>
89
<JustEatHttpClientInterceptionVersion>2.0.1</JustEatHttpClientInterceptionVersion>
910
<MartinCostelloLoggingXUnitVersion>0.1.0</MartinCostelloLoggingXUnitVersion>
1011
<MicrosoftSourceLinkGitHubVersion>1.0.0-beta2-19270-01</MicrosoftSourceLinkGitHubVersion>
11-
<OpenCoverVersion>4.7.922</OpenCoverVersion>
1212
<ReportGeneratorVersion>4.1.10</ReportGeneratorVersion>
1313
<ShouldlyVersion>3.0.2</ShouldlyVersion>
1414
<TwitterProviderVersion>3.0.0-preview6.19307.2</TwitterProviderVersion>
1515
<XunitVersion>2.4.1</XunitVersion>
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="OpenCover" Version="$(OpenCoverVersion)" PrivateAssets="All" />
19+
<PackageReference Include="coverlet.msbuild" Version="$(CoverletVersion)" PrivateAssets="All" />
2020
<PackageReference Include="ReportGenerator" Version="$(ReportGeneratorVersion)" PrivateAssets="All" />
2121
</ItemGroup>
2222

run.ps1

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -110,42 +110,17 @@ function DotNetTest {
110110
$propsFile = Join-Path $solutionPath "build"
111111
$propsFile = Join-Path $propsFile "dependencies.props"
112112

113-
$openCoverVersion = (Select-Xml -Path $propsFile -XPath "//OpenCoverVersion").Node.'#text'
114-
$openCoverPath = Join-Path $nugetPath "OpenCover\$openCoverVersion\tools\OpenCover.Console.exe"
115-
116113
$reportGeneratorVersion = (Select-Xml -Path $propsFile -XPath "//ReportGeneratorVersion").Node.'#text'
117114
$reportGeneratorPath = Join-Path $nugetPath "ReportGenerator\$reportGeneratorVersion\tools\netcoreapp2.0\ReportGenerator.dll"
118115

119-
$coverageOutput = Join-Path $OutputPath "code-coverage.xml"
116+
$coverageOutput = Join-Path $OutputPath "coverage.cobertura.xml"
120117
$reportOutput = Join-Path $OutputPath "coverage"
121118

122119
if ($null -ne $env:TF_BUILD) {
123-
& $openCoverPath `
124-
`"-target:$dotnetPath`" `
125-
`"-targetargs:test $Project --output $OutputPath --logger trx`" `
126-
-output:$coverageOutput `
127-
`"-excludebyattribute:System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage*`" `
128-
-hideskipped:All `
129-
-mergebyhash `
130-
-mergeoutput `
131-
-oldstyle `
132-
-register:user `
133-
-skipautoprops `
134-
`"-filter:+[AspNet.Security.OAuth.*]* -[AspNet.Security.OAuth.Providers.Tests]*`"
120+
& $dotnetPath test $Project --output $OutputPath --logger trx
135121
}
136122
else {
137-
& $openCoverPath `
138-
`"-target:$dotnetPath`" `
139-
`"-targetargs:test $Project --output $OutputPath`" `
140-
-output:$coverageOutput `
141-
`"-excludebyattribute:System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage*`" `
142-
-hideskipped:All `
143-
-mergebyhash `
144-
-mergeoutput `
145-
-oldstyle `
146-
-register:user `
147-
-skipautoprops `
148-
`"-filter:+[AspNet.Security.OAuth.*]* -[AspNet.Security.OAuth.Providers.Tests]*`"
123+
& $dotnetPath test $Project --output $OutputPath
149124
}
150125

151126
$dotNetTestExitCode = $LASTEXITCODE
@@ -154,7 +129,7 @@ function DotNetTest {
154129
$reportGeneratorPath `
155130
`"-reports:$coverageOutput`" `
156131
`"-targetdir:$reportOutput`" `
157-
-reporttypes:HTML`;Cobertura `
132+
-reporttypes:HTML `
158133
-verbosity:Warning
159134
}
160135

0 commit comments

Comments
 (0)