Any Cobertura
Cobertura XML code coverage report, read leniently as tools write it - e.g. coverage.py (coverage xml) or gcovr
(--cobertura).
Read by pyEDAA.Reports.CodeCoverage.Cobertura.Document - see Cobertura XML.
The schema has the structure of Cobertura’s DTD coverage-04.dtd, but accepts the attributes tools add - e.g.
coverage.py’s missing-branches - and requires only what a reader needs: a class’ filename, a line’s
number and hits. Cobertura-04.xsd is the DTD’s strict translation, and
CoveragePy-Cobertura.xsd describes coverage.py’s dialect strictly.
NVC-Cobertura.xsd describes NVC’s dialect, whose condition-coverage - e.g.
50 % - this schema rejects.
Download
Any-Cobertura.xsd (4.8 kiB)
Validate a report
xmllint --schema Any-Cobertura.xsd --noout coverage.xml
Source
1<?xml version="1.0" encoding="UTF-8"?>
2<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
3 <xs:annotation>
4 <xs:documentation>
5 Any Cobertura XML code coverage report: the structure of Cobertura's DTD 'coverage-04.dtd', read leniently.
6
7 Tools writing the format add attributes of their own - e.g. coverage.py's 'missing-branches' on a line - and leave
8 out some of the DTD's required ones, so only what a reader needs is required: a class' 'filename', a line's
9 'number' and 'hits'. Other attributes are allowed on every element. 'Cobertura-04.xsd' is the DTD's strict
10 translation.
11 </xs:documentation>
12 </xs:annotation>
13
14 <xs:simpleType name="Rate">
15 <xs:restriction base="xs:decimal">
16 <xs:minInclusive value="0"/>
17 <xs:maxInclusive value="1"/>
18 </xs:restriction>
19 </xs:simpleType>
20
21 <xs:attributeGroup name="Rates">
22 <xs:attribute name="line-rate" type="Rate"/>
23 <xs:attribute name="branch-rate" type="Rate"/>
24 <xs:attribute name="complexity" type="xs:decimal"/>
25 <xs:anyAttribute processContents="lax"/>
26 </xs:attributeGroup>
27
28 <xs:element name="coverage">
29 <xs:complexType>
30 <xs:sequence>
31 <xs:element name="sources" minOccurs="0">
32 <xs:complexType>
33 <xs:sequence>
34 <xs:element name="source" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
35 </xs:sequence>
36 </xs:complexType>
37 </xs:element>
38 <xs:element name="packages">
39 <xs:complexType>
40 <xs:sequence>
41 <xs:element ref="package" minOccurs="0" maxOccurs="unbounded"/>
42 </xs:sequence>
43 </xs:complexType>
44 </xs:element>
45 </xs:sequence>
46 <xs:attribute name="lines-covered" type="xs:nonNegativeInteger"/>
47 <xs:attribute name="lines-valid" type="xs:nonNegativeInteger"/>
48 <xs:attribute name="branches-covered" type="xs:nonNegativeInteger"/>
49 <xs:attribute name="branches-valid" type="xs:nonNegativeInteger"/>
50 <xs:attribute name="version" type="xs:string"/>
51 <xs:attribute name="timestamp" type="xs:string"/>
52 <xs:attributeGroup ref="Rates"/>
53 </xs:complexType>
54 </xs:element>
55
56 <xs:element name="package">
57 <xs:complexType>
58 <xs:sequence>
59 <xs:element name="classes">
60 <xs:complexType>
61 <xs:sequence>
62 <xs:element ref="class" minOccurs="0" maxOccurs="unbounded"/>
63 </xs:sequence>
64 </xs:complexType>
65 </xs:element>
66 </xs:sequence>
67 <xs:attribute name="name" type="xs:string" use="required"/>
68 <xs:attributeGroup ref="Rates"/>
69 </xs:complexType>
70 </xs:element>
71
72 <xs:element name="class">
73 <xs:complexType>
74 <xs:sequence>
75 <xs:element name="methods" minOccurs="0">
76 <xs:complexType>
77 <xs:sequence>
78 <xs:element ref="method" minOccurs="0" maxOccurs="unbounded"/>
79 </xs:sequence>
80 </xs:complexType>
81 </xs:element>
82 <xs:element ref="lines"/>
83 </xs:sequence>
84 <xs:attribute name="name" type="xs:string"/>
85 <xs:attribute name="filename" type="xs:string" use="required"/>
86 <xs:attributeGroup ref="Rates"/>
87 </xs:complexType>
88 </xs:element>
89
90 <xs:element name="method">
91 <xs:complexType>
92 <xs:sequence>
93 <xs:element ref="lines"/>
94 </xs:sequence>
95 <xs:attribute name="name" type="xs:string" use="required"/>
96 <xs:attribute name="signature" type="xs:string"/>
97 <xs:attributeGroup ref="Rates"/>
98 </xs:complexType>
99 </xs:element>
100
101 <xs:element name="lines">
102 <xs:complexType>
103 <xs:sequence>
104 <xs:element ref="line" minOccurs="0" maxOccurs="unbounded"/>
105 </xs:sequence>
106 </xs:complexType>
107 </xs:element>
108
109 <xs:element name="line">
110 <xs:complexType>
111 <xs:sequence>
112 <xs:element name="conditions" minOccurs="0">
113 <xs:complexType>
114 <xs:sequence>
115 <xs:element name="condition" minOccurs="0" maxOccurs="unbounded">
116 <xs:complexType>
117 <xs:attribute name="number" type="xs:nonNegativeInteger" use="required"/>
118 <xs:attribute name="type" type="xs:string"/>
119 <xs:attribute name="coverage" type="xs:string"/>
120 <xs:anyAttribute processContents="lax"/>
121 </xs:complexType>
122 </xs:element>
123 </xs:sequence>
124 </xs:complexType>
125 </xs:element>
126 </xs:sequence>
127 <xs:attribute name="number" type="xs:positiveInteger" use="required"/>
128 <xs:attribute name="hits" type="xs:nonNegativeInteger" use="required"/>
129 <xs:attribute name="branch" type="xs:boolean"/>
130 <xs:attribute name="condition-coverage" type="ConditionCoverage"/>
131 <xs:anyAttribute processContents="lax"/>
132 </xs:complexType>
133 </xs:element>
134
135 <xs:simpleType name="ConditionCoverage">
136 <xs:annotation>
137 <xs:documentation>Percentage and count of taken branches, e.g. '50% (1/2)'.</xs:documentation>
138 </xs:annotation>
139 <xs:restriction base="xs:string">
140 <xs:pattern value="\d+(\.\d+)?% \(\d+/\d+\)"/>
141 </xs:restriction>
142 </xs:simpleType>
143</xs:schema>