Skip to content

Add support to the latest Cobertura format #164

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

Closed
lmussier opened this issue Feb 13, 2017 · 8 comments
Closed

Add support to the latest Cobertura format #164

lmussier opened this issue Feb 13, 2017 · 8 comments

Comments

@lmussier
Copy link

Hi,

Could you add the support of the latest cobertura format coverage-04.dtd for xml output?

Thanks.

@lmussier lmussier changed the title Add support to Add support to the latest Cobertura format Feb 13, 2017
@ghost
Copy link

ghost commented Aug 15, 2017

Any idea of if/when this would happen to support TFS usage?

@shreyaskambl
Copy link

VSTS only accepts cobertura-04.dtd format. It would be great if we can have it implemented

@libPhipp
Copy link
Contributor

libPhipp commented Jan 6, 2018

That would be great indeed. The only difference between Cobertura's 03.dtd and the new 04.dtd is in the coverage element. Five new required attributes were introduced:

lines-covered
lines-valid
branches-covered
branches-valid
complexity

Does anyone know what information is expected in those attributes? Do we already have that elsewhere or may be at least the summands? Can we get the information from print_xml_report's parameter "covdata"?

@latk
Copy link
Member

latk commented Jan 6, 2018

This issue seems to be quite important.

The meaning of these attributes can probably be derived from the Cobertura implementation itself. Their XMLReport class looks like a good starting point. Since they use the same code to generate reports for all DTDs, we can do the same.

Calculating cyclomatic complexity is clearly out of scope for gcovr, but I think the other parameters can be derived from the CoverageData objects.

If someone wants to take a go at this:

  1. Run the XML tests to verify that gcovr currently works: python gcovr/tests/test_gcovr.py GcovrXml
  2. Add the new required attributes to the report and use the 04.dtd.
  3. Re-run the XML tests. They should now fail due to the added attributes.
  4. For each failing tests, compare the actual report with the reference XML report. If there are no discrepancies other than the new attributes, replace the reference file with the new report.
  5. The tests should now pass again.
  6. Create a pull request to the master branch and mention this issue in the description.

Perhaps we also need to add a command line flag so that the DTD version can be selected explicitly.

@denniswjackson
Copy link

denniswjackson commented Jan 7, 2018 via email

@libPhipp
Copy link
Contributor

libPhipp commented Jan 7, 2018

I gave it a try and created a pull request for this issue. For the complexity value I have just copied the fixed '0.0' that we also have in the package- and class-elements for example. The tests didn't fail as expected, after my changes, as assertMatchesXmlBaseline() from pyutilib.th doesn't seem to compare doctype nor attributes.

@latk latk mentioned this issue Jan 7, 2018
@latk
Copy link
Member

latk commented Jan 7, 2018

Thanks to @libPhipp's work in #186, we now use the newer Cobertura format.

Everyone: please test the current version with your setup (Jenkins plugins, VSTS, ...) and report any related problems in this thread.

To test this new feature, you must install gcovr directly from Github and not from PyPI. For example:

$ pip install git+https://github.com/gcovr/gcovr.git

@latk latk closed this as completed Jan 7, 2018
@latk latk removed the help wanted label Jan 7, 2018
@libPhipp
Copy link
Contributor

libPhipp commented Jan 8, 2018

Today I have tested the new state of the master branch in combination with VSTS and it works like a charm. The coverage statistics are now exported and also the html report can be included:
coverage

Thanks a lot for your amazing help, @latk !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants