การแสดงภาพการครอบคลุมโค้ดอันทรงพลัง
ReportGenerator แปลงรายงานความครอบคลุมที่สร้างโดย coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov หรือ lcov ให้เป็นรายงานที่มนุษย์สามารถอ่านได้ในรูปแบบต่างๆ
รายงานจะแสดงโควต้าความครอบคลุมและยังแสดงภาพบรรทัดซอร์สโค้ดของคุณที่ครอบคลุมอีกด้วย
ReportGenerator รองรับการรวมไฟล์ความครอบคลุมหลายไฟล์ไว้ในรายงานเดียว
เรียกดูตัวอย่างรายงาน HTML
ReportGenerator เป็นเครื่องมือบรรทัดคำสั่งที่ทำงานร่วมกับ .NET Framework และ .NET Core เต็มรูปแบบ
ใช้เครื่องมือกำหนดค่าออนไลน์เพื่อเริ่มต้นอย่างรวดเร็ว
บรรจุุภัณฑ์ | แพลตฟอร์ม | การติดตั้ง/การใช้งาน |
---|---|---|
เครื่องกำเนิดรายงาน | .NET Core >=8.0 .NET Framework 4.7 | ใช้แพ็คเกจนี้หากโปรเจ็กต์ของคุณใช้ .NET Framework หรือ .NET Core และคุณต้องการใช้ ReportGenerator ผ่านทางบรรทัดคำสั่งหรือสคริปต์บิลด์ การใช้งาน dotnet $(UserProfile).nugetpackagesreportgeneratorxyztoolsnet8.0ReportGenerator.dll [options] $(UserProfile).nugetpackagesreportgeneratorxyztoolsnet8.0ReportGenerator.exe [options] $(UserProfile).nugetpackagesreportgeneratorxyztoolsnet47ReportGenerator.exe [options] |
dotnet-reportgenerator-globaltool | .NET Core >=8.0 | ใช้แพ็คเกจนี้หากโครงการของคุณใช้ .NET Core และคุณต้องการใช้ ReportGenerator เป็น 'DotnetTool' (ทั่วโลก) การติดตั้ง dotnet tool install -g dotnet-reportgenerator-globaltool dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools dotnet new tool-manifest dotnet tool install dotnet-reportgenerator-globaltool การใช้งาน reportgenerator [options] toolsreportgenerator.exe [options] dotnet reportgenerator [options] |
ReportGenerator.Core | .NET มาตรฐาน 2.0 | ใช้แพ็คเกจนี้หากคุณต้องการเขียน ปลั๊กอิน แบบกำหนดเองสำหรับ ReportGenerator หรือหากคุณต้องการโทร/เรียกใช้ ReportGenerator ภายในฐานโค้ดของคุณ การพัฒนาปลั๊กอิน รายงานที่กำหนดเอง การจัดเก็บประวัติที่กำหนดเอง |
ส่วนขยาย Azure DevOps | .NET Core >=8.0 | เพิ่มส่วนขยาย Azure DevOps ให้กับไปป์ไลน์การสร้างของคุณ เรียนรู้เพิ่มเติม |
การดำเนินการ GitHub | .NET Core >=8.0 | เพิ่ม GitHub Action ลงในไปป์ไลน์บิวด์ของคุณ เรียนรู้เพิ่มเติม |
ใช้เครื่องมือกำหนดค่าออนไลน์เพื่อเริ่มต้นอย่างรวดเร็ว
การตั้งค่าขั้นสูงเพิ่มเติมได้รับการบันทึกไว้ในวิกิ
Parameters:
["]-reports:<report>[;<report>][;<report>]["]
["]-targetdir:<target directory>["]
[["]-reporttypes:<Html|HtmlSummary|...>[;<Html|HtmlSummary|...>]["]]
[["]-sourcedirs:<directory>[;<directory>][;<directory>]["]]
[["]-historydir:<history directory>["]]
[["]-plugins:<plugin>[;<plugin>][;<plugin>]["]]
[["]-assemblyfilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
[["]-classfilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
[["]-filefilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
[["]-riskhotspotassemblyfilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
[["]-riskhotspotclassfilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
[["]-verbosity:<Verbose|Info|Warning|Error|Off>["]]
[["]-title:<title>["]]
[["]-tag:<tag>["]]
[["]-license:<license>["]]
Explanations:
Reports: The coverage reports that should be parsed (separated by semicolon).
Globbing is supported.
Target directory: The directory where the generated report should be saved.
Report types: The output formats and scope (separated by semicolon).
Values: Badges, Clover, Cobertura, CsvSummary,
MarkdownSummary, MarkdownAssembliesSummary, MarkdownSummaryGithub, MarkdownDeltaSummary
OpenCover
Html, Html_Light, Html_Dark, Html_BlueRed
HtmlChart, HtmlInline, HtmlSummary, Html_BlueRed_Summary
HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Light, HtmlInline_AzurePipelines_Dark
JsonSummary, CodeClimate, Latex, LatexSummary, lcov, MHtml, SvgChart, SonarQube, TeamCitySummary
TextSummary, TextDeltaSummary
Xml, XmlSummary
Source directories: Optional directories which contain the corresponding source code (separated by semicolon).
The source directories are used if coverage report contains classes without path information.
Globbing is not supported.
History directory: Optional directory for storing persistent coverage information.
Can be used in future reports to show coverage evolution.
Plugins: Optional plugin files for custom reports or custom history storage (separated by semicolon).
Assembly filters: Optional list of assemblies that should be included or excluded in the report.
Class filters: Optional list of classes that should be included or excluded in the report.
File filters: Optional list of files that should be included or excluded in the report.
Risk hotspot assembly filters: Optional list of assemblies that should be included or excluded in the risk hotspots.
Risk hotspot class filters: Optional list of classes that should be included or excluded in the risk hotspots.
Exclusion filters take precedence over inclusion filters.
Wildcards are allowed.
Verbosity: The verbosity level of the log messages.
Values: Verbose, Info, Warning, Error, Off
Title: Optional title.
Tag: Optional tag or build version.
License: Optional license for PRO version. Get your license here: https://reportgenerator.io/pro
License can also be supplied via 'REPORTGENERATOR_LICENSE' environment variable.
Default values:
-reporttypes:Html
-assemblyfilters:+*
-classfilters:+*
-filefilters:+*
-riskhotspotassemblyfilters:+*
-riskhotspotclassfilters:+*
-verbosity:Info
Examples:
"-reports:coverage.xml" "-targetdir:C:report"
"-reports:target**.xml" "-targetdir:C:report" -reporttypes:Latex;HtmlSummary -title:IntegrationTest -tag:v1.4.5
"-reports:coverage1.xml;coverage2.xml" "-targetdir:report" "-sourcedirs:C:MyProject" -plugins:CustomReports.dll
"-reports:coverage.xml" "-targetdir:C:report" "-assemblyfilters:+Included;-Excluded.*"
พารามิเตอร์ข้างต้นทั้งหมดสามารถคงอยู่ในไฟล์ .netconfig ใต้ส่วน [ReportGenerator]
ตัวอย่าง:
[ ReportGenerator ]
reports = coverage.xml
targetdir = " C: \ report "
reporttypes = Latex,HtmlSummary
assemblyfilters = +Test,-Test
classfilters = +Test2,-Test2
ตัวเลือกพหูพจน์ทั้งหมดสามารถระบุเป็นรายการเอกพจน์หลายรายการได้ เช่น:
[ ReportGenerator ]
report = coverage1.xml
report = coverage2.xml
reporttype = Latex
reporttype = HtmlSummary
assemblyfilter = +Test
assemblyfilter = -Test
classfilter = +Test2
classfilter = -Test2
filefilter = +cs
filefilter = -vb
riskhotspotassemblyfilter = +Test
riskhotspotassemblyfilter = -Test
riskhotspotclassfilter = +Test2
riskhotspotclassfilter = -Test2
sourcedir = src
sourcedir = test
การเพิ่ม/การลบค่าเป็นเรื่องเล็กน้อยโดยใช้ dotnet-config CLI:
# set a single-valued variable
dotnet config reportgenerator.reporttypes Latex ; HtmlSummary
# add to multi-valued variable
dotnet config --add reportgenerator.report coverage3.xml
# clear all multi-valued entries for a variable
dotnet config --unset-all reportgenerator.assemblyfilter
แน่นอนว่าการแก้ไขไฟล์ .netconfig
ด้วยมือก็เป็นเรื่องเล็กน้อยไม่แพ้กัน
มีงาน MSBuild อยู่ด้วย:
<? xml version = " 1.0 " encoding = " utf-8 " ?>
< Project DefaultTargets = " Coverage " xmlns = " http://schemas.microsoft.com/developer/msbuild/2003 " ToolsVersion = " 4.0 " >
< ItemGroup >
< PackageReference Include = " ReportGenerator " Version = " x.y.z " />
</ ItemGroup >
< Target Name = " Coverage " >
< ItemGroup >
< CoverageFiles Include = " OpenCover.xml " />
</ ItemGroup >
< ReportGenerator ProjectDirectory = " $(MSBuildProjectDirectory) " ReportFiles = " @(CoverageFiles) " TargetDirectory = " report " ReportTypes = " Html;Latex " HistoryDirectory = " history " Plugins = " CustomReports.dll " AssemblyFilters = " +Include;-Excluded " VerbosityLevel = " Verbose " />
</ Target >
</ Project >
พารามิเตอร์งาน MSBuild สามารถเสริมด้วย .netconfig
ได้ หากใช้ นั่นหมายความว่าสามารถละเว้นพารามิเตอร์ได้หากระบุผ่าน .netconfig
ซึ่งมีประโยชน์เมื่อใช้การตั้งค่าคงที่ซ้ำในหลาย ๆ โปรเจ็กต์ในโซลูชัน โดยที่งาน MSBuild จะให้ค่าไดนามิกสำหรับโปรเจ็กต์ปัจจุบันเท่านั้น:
รับ .netconfig
ต่อไปนี้:
[ ReportGenerator ]
reporttypes = Html ; Latex
targetdirectory = report
historydirectory = history
assemblyfilters = +Include ; -Excluded
verbosityLevel = Verbose
เป้าหมายข้างต้นสามารถทำให้ง่ายขึ้นดังนี้:
< Target Name = " Coverage " >
< ItemGroup >
< CoverageFiles Include = " OpenCover.xml " />
</ ItemGroup >
< ReportGenerator ProjectDirectory = " $(MSBuildProjectDirectory) "
ReportFiles = " @(CoverageFiles) "
Plugins = " CustomReports.dll " />
</ Target >
ReportGenerator รองรับรูปแบบอินพุตและเอาต์พุตหลายรูปแบบ
วิกิจะอธิบายรูปแบบเอาต์พุตต่างๆ หรือคุณสามารถดาวน์โหลดรายงานตัวอย่างของรูปแบบเอาต์พุตที่รองรับทั้งหมดได้
หากคุณต้องการรูปแบบที่กำหนดเอง คุณสามารถสร้างปลั๊กอินได้
รูปแบบการป้อนข้อมูล | รูปแบบเอาต์พุต |
---|---|
|
|
ภาพหน้าจอแสดงตัวอย่างรายงานที่สร้างขึ้นสองส่วน: