@@ -13,10 +13,12 @@ public class CoberturaReporter : IReporter
13
13
14
14
public string Report ( CoverageResult result )
15
15
{
16
+ CoverageSummary summary = new CoverageSummary ( ) ;
17
+
16
18
XmlDocument xml = new XmlDocument ( ) ;
17
19
XmlElement coverage = xml . CreateElement ( "coverage" ) ;
18
- coverage . SetAttribute ( "line-rate" , "0" ) ;
19
- coverage . SetAttribute ( "branch-rate" , "0" ) ;
20
+ coverage . SetAttribute ( "line-rate" , summary . CalculateLineCoverage ( result . Modules ) . ToString ( ) ) ;
21
+ coverage . SetAttribute ( "branch-rate" , summary . CalculateBranchCoverage ( result . Modules ) . ToString ( ) ) ;
20
22
coverage . SetAttribute ( "version" , "1.9" ) ;
21
23
coverage . SetAttribute ( "timestamp" , "0" ) ;
22
24
@@ -32,8 +34,8 @@ public string Report(CoverageResult result)
32
34
foreach ( var module in result . Modules )
33
35
{
34
36
XmlElement package = xml . CreateElement ( "package" ) ;
35
- package . SetAttribute ( "line-rate" , "0" ) ;
36
- package . SetAttribute ( "branch-rate" , "0" ) ;
37
+ package . SetAttribute ( "line-rate" , summary . CalculateLineCoverage ( module . Value ) . ToString ( ) ) ;
38
+ package . SetAttribute ( "branch-rate" , summary . CalculateBranchCoverage ( module . Value ) . ToString ( ) ) ;
37
39
package . SetAttribute ( "complexity" , "0" ) ;
38
40
39
41
XmlElement classes = xml . CreateElement ( "classes" ) ;
@@ -44,8 +46,8 @@ public string Report(CoverageResult result)
44
46
XmlElement @class = xml . CreateElement ( "class" ) ;
45
47
@class . SetAttribute ( "name" , cls . Key ) ;
46
48
@class . SetAttribute ( "filename" , Path . GetFileName ( document . Key ) ) ;
47
- @class . SetAttribute ( "line-rate" , "0" ) ;
48
- @class . SetAttribute ( "branch-rate" , "0" ) ;
49
+ @class . SetAttribute ( "line-rate" , summary . CalculateLineCoverage ( cls . Value ) . ToString ( ) ) ;
50
+ @class . SetAttribute ( "branch-rate" , summary . CalculateBranchCoverage ( cls . Value ) . ToString ( ) ) ;
49
51
@class . SetAttribute ( "complexity" , "0" ) ;
50
52
51
53
XmlElement methods = xml . CreateElement ( "methods" ) ;
@@ -54,8 +56,8 @@ public string Report(CoverageResult result)
54
56
XmlElement method = xml . CreateElement ( "method" ) ;
55
57
method . SetAttribute ( "name" , meth . Key . Split ( ':' ) [ 2 ] . Split ( '(' ) [ 0 ] ) ;
56
58
method . SetAttribute ( "signature" , meth . Key ) ;
57
- method . SetAttribute ( "line-rate" , "0" ) ;
58
- method . SetAttribute ( "branch-rate" , "0" ) ;
59
+ method . SetAttribute ( "line-rate" , summary . CalculateLineCoverage ( meth . Value ) . ToString ( ) ) ;
60
+ method . SetAttribute ( "branch-rate" , summary . CalculateBranchCoverage ( meth . Value ) . ToString ( ) ) ;
59
61
60
62
XmlElement lines = xml . CreateElement ( "lines" ) ;
61
63
foreach ( var ln in meth . Value )
0 commit comments