Cobertura coverage-04.dtd support

Issue #570 resolved
Alex Lowe created an issue

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 could support it.

Comments (8)

  1. Ned Batchelder repo owner

    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 will support.

    Help me understand what v4 support would mean for you.

  2. Alex Lowe reporter

    For me in particular it would mean the ability to use 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,

    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.

  3. Ned Batchelder repo owner

    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?

  4. Alex Lowe reporter

    VSTS is pretty much a black box about why it cannot read coverage data - all I receive when giving it a coverage file from 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 to add those four required fields to the <coverage> tag, and it consumed the file without error. So it appears to be that it's only looking for presence of attributes.

  5. Alex Lowe reporter

    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 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 (, 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.

  6. Log in to comment