Skip to content
Novus Examples
xml12.9 KB

Coverage — Cobertura XML

The Cobertura serialisation of the same run, with packages, classes, per-method line rates and condition-coverage attributes on every branching line. Cobertura expresses coverage as rates rather than counts, so this is the file that catches converters rounding a percentage into a hit count. Every file in this group describes the same four-file source tree and reports 127/140 lines, 17/24 branch outcomes and 18/20 functions, so a converter can be diffed against a known answer.

Preview — first 50 linesxml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage line-rate="0.9071" branch-rate="0.7083" lines-covered="127" lines-valid="140" branches-covered="17" branches-valid="24" complexity="32" version="2.1.1" timestamp="1786000462">
  <sources>
    <source>src</source>
  </sources>
  <packages>
    <package name="cart" line-rate="0.8831" branch-rate="0.7143" complexity="11">
      <classes>
        <class name="pricing" filename="src/cart/pricing.js" line-rate="0.9091" branch-rate="0.7500" complexity="6">
          <methods>
            <method name="unitPrice" signature="()V" line-rate="1.0" branch-rate="1.0">
              <lines><line number="2" hits="25"/></lines>
            </method>
            <method name="quantityMultiplier" signature="()V" line-rate="1.0" branch-rate="1.0">
              <lines><line number="8" hits="8"/></lines>
            </method>
            <method name="roundHalfUp" signature="()V" line-rate="1.0" branch-rate="1.0">
              <lines><line number="13" hits="9"/></lines>
            </method>
            <method name="applyTax" signature="()V" line-rate="1.0" branch-rate="1.0">
              <lines><line number="19" hits="37"/></lines>
            </method>
            <method name="bulkRate" signature="()V" line-rate="1.0" branch-rate="1.0">
              <lines><line number="25" hits="35"/></lines>
            </method>
            <method name="convertCurrency" signature="()V" line-rate="0.0" branch-rate="1.0">
              <lines><line number="31" hits="0"/></lines>
            </method>
          </methods>
          <lines>
            <line number="2" hits="13" branch="false"/>
            <line number="3" hits="21" branch="false"/>
            <line number="4" hits="23" branch="false"/>
            <line number="5" hits="10" branch="true" condition-coverage="100% (2/2)"/>
            <line number="6" hits="8" branch="false"/>
            <line number="8" hits="2" branch="false"/>
            <line number="9" hits="47" branch="false"/>
            <line number="10" hits="2" branch="false"/>
            <line number="11" hits="0" branch="false"/>
            <line number="12" hits="29" branch="false"/>
            <line number="13" hits="41" branch="false"/>
            <line number="15" hits="14" branch="true" condition-coverage="100% (2/2)"/>
            <line number="16" hits="36" branch="false"/>
            <line number="17" hits="40" branch="false"/>
            <line number="18" hits="5" branch="false"/>
            <line number="19" hits="33" branch="false"/>
            <line number="20" hits="0" branch="false"/>
            <line number="22" hits="47" branch="false"/>
            <line number="23" hits="18" branch="false"/>
242 lines total — download for the full file.

Specifications

Seed
61200
Source Files
4
Lines Found
140
Lines Hit
127
Line Pct
90.71
Branches Found
24
Branches Hit
17
Branch Pct
70.83
Functions Found
20
Functions Hit
18
Line Endings
LF
Format
Cobertura XML
Packages
2
Line Rate
0.9071
Branch Rate
0.7083
Has Condition Coverage
true
Doctype
coverage-04.dtd

Testing contract

Expected to pass
Scenario
Convert Cobertura XML into raw covered/valid counts.
Expected result
line-rate 0.9071 recovers exactly 127/140 lines, matching the LCOV twin.

What is a .xml file?

XML (Extensible Markup Language) is a verbose, self-describing markup language using nested tags, attributes, and namespaces to represent structured, hierarchical data. It supports schemas, entities, and validation and underlies many document and data formats. It remains common in enterprise, publishing, and interchange contexts.

How to use this file

Use an example XML file to test parsers, namespace and schema validation, XPath queries, and protection against entity-expansion and external-entity attacks.

How to use this file for testing

“Coverage — Cobertura XML” is a deterministic Novus Examples fixture for Conversion testing, Code parsing, Schema validation. The same content exported across many formats and linked as a group, so you can convert one and diff against the expected twin.

Documented properties for this file: seed 61200 · LF · Cobertura XML. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Test and coverage reports document their totals (suites, cases, passes, failures, skips, covered lines) in the spec table. Point your CI dashboard, coverage gate, or report converter at the file and assert those counts survive; format twins carry identical numbers so a conversion can be scored exactly.

Code examples

import xml.etree.ElementTree as ET

tree = ET.parse("cobertura-coverage.xml")
root = tree.getroot()
print(root.tag, [c.tag for c in root][:5])

Generated by generation/testing.py. Free for any use, no attribution required — license.