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 coverage-04.dtd support #570

Closed
nedbat opened this issue Apr 3, 2017 · 7 comments
Closed

Cobertura coverage-04.dtd support #570

nedbat opened this issue Apr 3, 2017 · 7 comments
Labels
enhancement New feature or request xml

Comments

@nedbat
Copy link
Owner

nedbat commented Apr 3, 2017

Originally reported by Alex Lowe (Bitbucket: amlowe-hcbb, GitHub: Unknown)


I don't know what it would require to be able to support Cobertura's v4 Document Type Definition, but it would be great if coverage.py could support it.


@nedbat
Copy link
Owner Author

nedbat commented Apr 3, 2017

Looks like v4 adds:

<!ATTLIST coverage lines-covered    CDATA #REQUIRED>
<!ATTLIST coverage lines-valid      CDATA #REQUIRED>
<!ATTLIST coverage branches-covered CDATA #REQUIRED>
<!ATTLIST coverage branches-valid   CDATA #REQUIRED>
<!ATTLIST coverage complexity       CDATA #REQUIRED>

I don't know what "lines-covered" and "branches-covered" mean. "lines-valid", "branches-valid", and "complexity" don't sound like something coverage.py will support.

Help me understand what v4 support would mean for you.

@nedbat
Copy link
Owner Author

nedbat commented Apr 3, 2017

Original comment by Alex Lowe (Bitbucket: amlowe-hcbb, GitHub: Unknown)


For me in particular it would mean the ability to use coverage.py with Visual Studio Team Services, of which my company has mandated use and which only supports the v4 files.

From what I understand, lines-valid is the count of lines of code and branches-valid is the total number of branches. They appear to be the values lnum_tot and bnum_tot in XMLReporter.report,

complexity is the average McCabe number of the project. It looks like this is already set to 0 on a per class and per package level, so could probably feasibly be set to 0 for the overview.

@nedbat
Copy link
Owner Author

nedbat commented Apr 4, 2017

The XML we produce already includes an attribute that is not in the Cobertura DTD: "missing-branches". Are you sure that VSTS will be ok with this? How is it rejecting the file now? Will it require an actual DTD reference, or just the presence of the attributes it is looking for?

@nedbat
Copy link
Owner Author

nedbat commented Apr 4, 2017

Original comment by Alex Lowe (Bitbucket: amlowe-hcbb, GitHub: Unknown)


VSTS is pretty much a black box about why it cannot read coverage data - all I receive when giving it a coverage file from coverage.py is a warning line stating "No coverage data found. Check the build errors/warnings for more details." However, I modified the coverage.xml generated by coverage.py to add those four required fields to the tag, and it consumed the file without error. So it appears to be that it's only looking for presence of attributes.

@nedbat
Copy link
Owner Author

nedbat commented Apr 4, 2017

I've added the attributes in b2951020ad92 (bb). If you can, please try this code and let me know how it works.

@nedbat
Copy link
Owner Author

nedbat commented Apr 5, 2017

This is in 4.4b1.

@nedbat
Copy link
Owner Author

nedbat commented Apr 5, 2017

Original comment by Alex Lowe (Bitbucket: amlowe-hcbb, GitHub: Unknown)


4.4b1 is working fantastically for me with VSTS. Thank you!

For future reference for anyone who comes across this thread while trying to get coverage.py and/or pytest to work with VSTS:

The way we built our structure was using the shell script task. pytest is writing a junit-style XML file to ${COMMON_TESTRESULTSDIRECTORY}/test_results.xml and an HTML coverage report to ${COMMON_TESTRESULTSDIRECTORY}/coverage. The XML report is written to ${COMMON_TESTRESULTSDIRECTORY}/coverage.xml.

The HTML report is a bit broken inside of Visual Studio (microsoft/azure-pipelines-tasks#3027), but if you want/need it, you can always download it as a Zip file using "Download Code Coverage Results" from the summary page. The XML is the primary source of our coverage data anyway.

@nedbat nedbat closed this as completed Apr 5, 2017
@nedbat nedbat added major enhancement New feature or request xml labels Jun 23, 2018
samssann pushed a commit to samssann/covr that referenced this issue Sep 27, 2018
Modified 'coverage' xml node to include:
- lines-covered (number of lines where there were no hits)
- lines-valid (number of lines of code)
- branches-covered (covr does not calculate branching, set to 0)
- branches-valid (covr does not calculate branching, set to 0)
- complexity (covr does not calculate complexity, set to 0)

Further detail:
- nedbat/coveragepy#570
- https://github.com/cobertura/web/tree/master/htdocs/xml
jimhester pushed a commit to r-lib/covr that referenced this issue Nov 5, 2018
* Support for v4 cobertura report

Modified 'coverage' xml node to include:
- lines-covered (number of lines where there were no hits)
- lines-valid (number of lines of code)
- branches-covered (covr does not calculate branching, set to 0)
- branches-valid (covr does not calculate branching, set to 0)
- complexity (covr does not calculate complexity, set to 0)

Further detail:
- nedbat/coveragepy#570
- https://github.com/cobertura/web/tree/master/htdocs/xml

* Update cobertura.R

styling editions

* Update NEWS.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request xml
Projects
None yet
Development

No branches or pull requests

1 participant