avatar
童琦杰
Nov 30, 2018Technology

.Net Core - 代码覆盖率

OpenCover

NuGet: https://www.nuget.org/packages/OpenCover/

安装: Install-Package OpenCover -Version 4.6.519

csproj文件添加: <DebugType>Full</DebugType>

shell
cd C:\Users\用户名\.nuget\packages\opencover\4.6.519\tools

OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test xUnit项目csproj路径" -register:user -filter:"+[*]* -[xunit*]*" -oldStyle -output:"Xml报告文件路径"

OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test D:\git\qi\test\Qi.xUnit\Qi.xUnit.csproj" -register:user -filter:"+[*]* -[xunit*]*" -oldStyle -output:"d:\report.xml"

ReportGenerator

NuGet: https://www.nuget.org/packages/ReportGenerator/

安装: Install-Package ReportGenerator -Version 4.0.4

语法:https://danielpalme.github.io/ReportGenerator/usage.html

shell
dotnet C:\Users\用户名\.nuget\packages\reportgenerator\4.0.4\tools\netcoreapp2.0\ReportGenerator.dll "-reports:OpenCover产生的Xml报告文件路径" "-targetdir:Html报告生成目录"

dotnet C:\Users\tongqijie\.nuget\packages\reportgenerator\4.0.4\tools\netcoreapp2.0\ReportGenerator.dll "-reports:d:\report.xml" "-targetdir:d:\output"
© 2015-2022 tongqijie.com 版权所有沪ICP备17000682号