Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Generate own report from cobertura #49

Open
tonyhallett opened this issue Dec 22, 2020 · 3 comments
Open

Feature - Generate own report from cobertura #49

tonyhallett opened this issue Dec 22, 2020 · 3 comments
Assignees
Labels
custom report custom report feature

Comments

@tonyhallett
Copy link
Collaborator

If dotnet-reportgenerator-globaltool changes its internal data structure then the report window will no longer work

@tonyhallett
Copy link
Collaborator Author

Background for anyone taking on this feature.

Code required to understand own report generation

  • Coverlet

https://github.com/coverlet-coverage/coverlet/blob/fe6fee996889ac3a5e98f786ad94262260db79a4/src/coverlet.core/Reporters/IReporter.cs#L8

Here are built in reporters
https://github.com/coverlet-coverage/coverlet/blob/fe6fee996889ac3a5e98f786ad94262260db79a4/src/coverlet.core/Reporters/ReporterFactory.cs

The cobertura reporter
https://github.com/coverlet-coverage/coverlet/blob/fe6fee996889ac3a5e98f786ad94262260db79a4/src/coverlet.core/Reporters/CoberturaReporter.cs


public static CoverageReport ProcessCoberturaXmlFile(string xmlFilePath, out List<CoverageLine> coverageLines)


		public static CoverageReport ProcessCoberturaXmlFile(string xmlFilePath, out List<CoverageLine> coverageLines)
		{
			coverageLines = new List<CoverageLine>();

			var report = LoadReportFile(xmlFilePath);

                        // the report is deserialized cobertura - create report from it !

			foreach (var package in report.Packages.Package)
			{
				foreach (var classs in package.Classes.Class)
				{
					foreach (var line in classs.Lines.Line)
					{
						coverageLines.Add(new CoverageLine
						{
							Package = package,
							Class = classs,
							Line = line
						});
					}
				}
			}

			return report;
		}

The unified xml is deserialized in to the CoverageReport class.

It should be relatively simple to create a wpf table that replicates the html report

@tonyhallett
Copy link
Collaborator Author

@tonyhallett
Copy link
Collaborator Author

@FortuneN

Further to our video call discussion where it was desired for the microserver to return the report in a generic format.
I was thinking using json over xml as would be better for html report generation.

The change could be as simple as

//unifiedJson - report type and path to change, may even be beneficial providing a custom IReportBuilder.  Can remove
//autogenerated classes with the report generator class filter.
ReportGeneratorUtil.RunReportGenerator(coverOutputFiles, darkMode, out var unifiedJson, out var unifiedXmlFile, true); 

//new method
//this will just set a var on the page to be processed by javascript again calling back through window.external
GenerateHtmlFile(unifiedJson,darkMode,out var coverageHTML )

A) Do you want to continue using an html file in visual studio ?
If so
How would you like the js ? Vanilla, knockout or react ? If the latter do you want scripts embedded in the page ?
How would you like this tested ? Puppeteer or something specific to framework if used ?
Do you want to leave it up to me ? I will replicate current functionality with the addition of branch coverage. If desired I can add the grouping and filtering that report generator provides.
image
Later can incorporate visual studio options for the report display.

I am good to do this tomorrow.

@tonyhallett tonyhallett added the custom report custom report feature label Feb 7, 2021
@tonyhallett tonyhallett self-assigned this Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom report custom report feature
Projects
None yet
Development

No branches or pull requests

1 participant