Skip to content

Commit b41fce9

Browse files
committed
#364: Added tooltips to show coverage as ratio
1 parent adf333f commit b41fce9

File tree

8 files changed

+66
-14
lines changed

8 files changed

+66
-14
lines changed

src/AngularComponents/src/app/components/coverageinfo/class-row.component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
5252
{{clazz.totalLines}}
5353
</ng-container>
5454
</td>
55-
<td class="right" [title]="clazz.coverageType">
55+
<td class="right" [title]="clazz.coverageType + ': ' + clazz.coverageRatioText">
5656
<div coverage-history-chart [historicCoverages]="clazz.lineCoverageHistory"
5757
*ngIf="clazz.lineCoverageHistory.length > 1"
5858
[ngClass]="{'historiccoverageoffset': clazz.currentHistoricCoverage !== null}"
@@ -62,14 +62,14 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
6262
<div class="currenthistory {{getClassName(clazz.coverage, clazz.currentHistoricCoverage.lcq)}}">
6363
{{clazz.coveragePercentage}}
6464
</div>
65-
<div [title]="clazz.currentHistoricCoverage.et">{{clazz.currentHistoricCoverage.lcq}}%</div>
65+
<div [title]="clazz.currentHistoricCoverage.et + ': ' + clazz.currentHistoricCoverage.coverageRatioText">{{clazz.currentHistoricCoverage.lcq}}%</div>
6666
</ng-container>
6767
<ng-container *ngIf="clazz.currentHistoricCoverage === null">
6868
{{clazz.coveragePercentage}}
6969
</ng-container>
7070
</td>
7171
<td class="right"><coverage-bar [percentage]="clazz.coverage"></coverage-bar></td>
72-
<td class="right" *ngIf="branchCoverageAvailable">
72+
<td class="right" *ngIf="branchCoverageAvailable" [title]="clazz.branchCoverageRatioText">
7373
<div coverage-history-chart [historicCoverages]="clazz.branchCoverageHistory"
7474
*ngIf="clazz.branchCoverageHistory.length > 1"
7575
[ngClass]="{'historiccoverageoffset': clazz.currentHistoricCoverage !== null}"
@@ -79,7 +79,7 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
7979
<div class="currenthistory {{getClassName(clazz.branchCoverage, clazz.currentHistoricCoverage.bcq)}}">
8080
{{clazz.branchCoveragePercentage}}
8181
</div>
82-
<div [title]="clazz.currentHistoricCoverage.et">{{clazz.currentHistoricCoverage.bcq}}%</div>
82+
<div [title]="clazz.currentHistoricCoverage.et + ': ' + clazz.currentHistoricCoverage.branchCoverageRatioText">{{clazz.currentHistoricCoverage.bcq}}%</div>
8383
</ng-container>
8484
<ng-container *ngIf="clazz.currentHistoricCoverage === null">
8585
{{clazz.branchCoveragePercentage}}

src/AngularComponents/src/app/components/coverageinfo/codeelement-row.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { CodeElementViewModel } from "./viewmodels/codelement-viewmodel.class";
1212
<th class="right">{{element.uncoveredLines}}</th>
1313
<th class="right">{{element.coverableLines}}</th>
1414
<th class="right">{{element.totalLines}}</th>
15-
<th class="right">{{element.coveragePercentage}}</th>
15+
<th class="right" [title]="element.coverageRatioText">{{element.coveragePercentage}}</th>
1616
<th class="right"><coverage-bar [percentage]="element.coverage"></coverage-bar></th>
17-
<th class="right" *ngIf="branchCoverageAvailable">{{element.branchCoveragePercentage}}</th>
17+
<th class="right" *ngIf="branchCoverageAvailable" [title]="element.branchCoverageRatioText">{{element.branchCoveragePercentage}}</th>
1818
<th class="right" *ngIf="branchCoverageAvailable">
1919
<coverage-bar [percentage]="element.branchCoverage"></coverage-bar>
2020
</th>`,

src/AngularComponents/src/app/components/coverageinfo/data/historic-coverage.class.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class HistoricCoverage {
22
/*
3-
* The branchCoverageQuota.
3+
* The execution time.
44
*/
55
et: string = "";
66

@@ -43,4 +43,32 @@ export class HistoricCoverage {
4343
* The branchCoverageQuota.
4444
*/
4545
bcq: number;
46+
47+
constructor(hc: HistoricCoverage) {
48+
this.et = hc.et;
49+
this.cl = hc.cl;
50+
this.ucl = hc.ucl;
51+
this.cal = hc.cal;
52+
this.tl = hc.tl;
53+
this.lcq = hc.lcq;
54+
this.cb = hc.cb;
55+
this.tb = hc.tb;
56+
this.bcq = hc.bcq;
57+
}
58+
59+
get coverageRatioText(): string {
60+
if (this.tl === 0) {
61+
return "-";
62+
}
63+
64+
return this.cl + "/" + this.cal;
65+
}
66+
67+
get branchCoverageRatioText(): string {
68+
if (this.tb === 0) {
69+
return "-";
70+
}
71+
72+
return this.cb + "/" + this.tb;
73+
}
4674
}

src/AngularComponents/src/app/components/coverageinfo/viewmodels/class-viewmodel.class.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export class ClassViewModel extends ElementBase {
3333

3434
this.lineCoverageHistory = clazz.lch;
3535
this.branchCoverageHistory = clazz.bch;
36-
this.historicCoverages = clazz.hc;
36+
37+
clazz.hc.forEach(element => {
38+
this.historicCoverages.push(new HistoricCoverage(element))
39+
});
3740
}
3841

3942
get coverage(): number {

src/AngularComponents/src/app/components/coverageinfo/viewmodels/elementbase.class.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,21 @@ export abstract class ElementBase {
2727
return this.coverage + "%";
2828
}
2929

30+
get coverageRatioText(): string {
31+
if (this.coverableLines === 0) {
32+
return "-";
33+
}
34+
35+
return this.coveredLines + "/" + this.coverableLines;
36+
}
37+
3038
get branchCoverage(): number {
3139
if (this.totalBranches === 0) {
3240
return NaN;
3341
}
3442

3543
return Helper.roundNumber(100 * this.coveredBranches / this.totalBranches, 1);
3644
}
37-
3845
get branchCoveragePercentage(): string {
3946
if (this.totalBranches === 0) {
4047
return "";
@@ -43,6 +50,14 @@ export abstract class ElementBase {
4350
return this.branchCoverage + "%";
4451
}
4552

53+
get branchCoverageRatioText(): string {
54+
if (this.totalBranches === 0) {
55+
return "-";
56+
}
57+
58+
return this.coveredBranches + "/" + this.totalBranches;
59+
}
60+
4661
abstract visible(filter: string, historicCoverageFilter: string): boolean;
4762

4863
abstract updateCurrentHistoricCoverage(historyComparisionDate: string): void;

src/Readme.txt

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ For further details take a look at LICENSE.txt.
6363

6464
CHANGELOG
6565

66+
4.6.3.0
67+
68+
* New: #364: Added tooltips to show coverage as ratio
69+
6670
4.6.2.0
6771

6872
* New: Clover: Added classfilter support

src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1024,14 +1024,15 @@ public void SummaryAssembly(Assembly assembly, bool branchCoverageAvailable)
10241024
this.reportTextWriter.Write("<th class=\"right\">{0}</th>", assembly.TotalLines.GetValueOrDefault());
10251025
this.reportTextWriter.Write(
10261026
"<th title=\"{0}\" class=\"right\">{1}</th>",
1027-
assembly.CoverageQuota.HasValue ? CoverageType.LineCoverage.ToString() : string.Empty,
1027+
assembly.CoverageQuota.HasValue ? $"{CoverageType.LineCoverage}: {assembly.CoveredLines}/{assembly.CoverableLines}" : string.Empty,
10281028
assembly.CoverageQuota.HasValue ? assembly.CoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
10291029
this.reportTextWriter.Write("<th>{0}</th>", CreateCoverageTable(assembly.CoverageQuota));
10301030

10311031
if (branchCoverageAvailable)
10321032
{
10331033
this.reportTextWriter.Write(
1034-
"<th class=\"right\">{0}</th>",
1034+
"<th class=\"right\" title=\"{0}\">{1}</th>",
1035+
assembly.BranchCoverageQuota.HasValue ? $"{assembly.CoveredBranches}/{assembly.TotalBranches}" : "-",
10351036
assembly.BranchCoverageQuota.HasValue ? assembly.BranchCoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
10361037
this.reportTextWriter.Write("<th>{0}</th>", CreateCoverageTable(assembly.BranchCoverageQuota));
10371038
}
@@ -1070,14 +1071,15 @@ public void SummaryClass(Class @class, bool branchCoverageAvailable)
10701071
this.reportTextWriter.Write("<td class=\"right\">{0}</td>", @class.TotalLines.GetValueOrDefault());
10711072
this.reportTextWriter.Write(
10721073
"<td title=\"{0}\" class=\"right\">{1}</td>",
1073-
@class.CoverageType,
1074+
@class.CoverageQuota.HasValue ? $"{@class.CoverageType}: {@class.CoveredLines}/{@class.CoverableLines}" : @class.CoverageType.ToString(),
10741075
@class.CoverageQuota.HasValue ? @class.CoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
10751076
this.reportTextWriter.Write("<td>{0}</td>", CreateCoverageTable(@class.CoverageQuota));
10761077

10771078
if (branchCoverageAvailable)
10781079
{
10791080
this.reportTextWriter.Write(
1080-
"<td class=\"right\">{0}</td>",
1081+
"<td class=\"right\" title=\"{0}\">{1}</td>",
1082+
@class.BranchCoverageQuota.HasValue ? $"{@class.CoveredBranches}/{@class.TotalBranches}" : "-",
10811083
@class.BranchCoverageQuota.HasValue ? @class.BranchCoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
10821084
this.reportTextWriter.Write("<td>{0}</td>", CreateCoverageTable(@class.BranchCoverageQuota));
10831085
}

src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)