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

cobertura: emit line and branch coverage for each method #720

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RoadTrain
Copy link

@RoadTrain RoadTrain commented Apr 29, 2023

Cobertura is usually structured in way that line coverage is presented for both classes and methods, i.e. each method definition contains line coverage for code within a method, while a class definition contain line coverage for the entire class. Currently istanbuljs emits only 1 line per method (method declaration) while correctly emitting coverage for classes.

See danielpalme/ReportGenerator#603 for more context.

This PR improves Cobertura generation so that for each method there is separate line coverage data.

@RoadTrain
Copy link
Author

TODO: Fix tests

@bcoe
Copy link
Member

bcoe commented Jul 25, 2023

@RoadTrain I have never used the Cobertura format myself and am open to suggestions if you can get tests passing. I would also like to make sure that we don't break tests in major dependencies like c8 and nyc.

@RoadTrain
Copy link
Author

A quick update. I will try to get back to it soon. Some tests were broken even before my changes, so I have to makes sure they are fixed in a correct way.

@RoadTrain
Copy link
Author

For future reference, there's an official Cobertura spec, which specifies line data for methods: https://github.com/cobertura/cobertura/blob/master/cobertura/src/site/htdocs/xml/coverage-04.dtd

The original cobertura tool (for java projects) emits methods with all line data corresponding to each particular method: https://github.com/cobertura/cobertura/blob/0ff963284cecaace30f409a977dccb07c41a5a8f/cobertura/src/main/java/net/sourceforge/cobertura/reporting/xml/XMLReport.java#L215

C# coverlet cobertura reporter does the same: https://github.com/coverlet-coverage/coverlet/blob/cceb71d758a57425ef54ca6bf9f0e443dfe378c5/src/coverlet.core/Reporters/CoberturaReporter.cs#L125

So this PR is basically bringing instanbuljs cobertura reporter in line with other reporters.

Hopefully I can get it finished after tests are fixed (#748).

@RoadTrain RoadTrain changed the title cobertura: emit line coverage for each method cobertura: emit line and branch coverage for each method Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants