Skip to content

Commit

Permalink
#364: Added tooltips to show coverage as ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Jul 31, 2020
1 parent adf333f commit b41fce9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
{{clazz.totalLines}}
</ng-container>
</td>
<td class="right" [title]="clazz.coverageType">
<td class="right" [title]="clazz.coverageType + ': ' + clazz.coverageRatioText">
<div coverage-history-chart [historicCoverages]="clazz.lineCoverageHistory"
*ngIf="clazz.lineCoverageHistory.length > 1"
[ngClass]="{'historiccoverageoffset': clazz.currentHistoricCoverage !== null}"
Expand All @@ -62,14 +62,14 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
<div class="currenthistory {{getClassName(clazz.coverage, clazz.currentHistoricCoverage.lcq)}}">
{{clazz.coveragePercentage}}
</div>
<div [title]="clazz.currentHistoricCoverage.et">{{clazz.currentHistoricCoverage.lcq}}%</div>
<div [title]="clazz.currentHistoricCoverage.et + ': ' + clazz.currentHistoricCoverage.coverageRatioText">{{clazz.currentHistoricCoverage.lcq}}%</div>
</ng-container>
<ng-container *ngIf="clazz.currentHistoricCoverage === null">
{{clazz.coveragePercentage}}
</ng-container>
</td>
<td class="right"><coverage-bar [percentage]="clazz.coverage"></coverage-bar></td>
<td class="right" *ngIf="branchCoverageAvailable">
<td class="right" *ngIf="branchCoverageAvailable" [title]="clazz.branchCoverageRatioText">
<div coverage-history-chart [historicCoverages]="clazz.branchCoverageHistory"
*ngIf="clazz.branchCoverageHistory.length > 1"
[ngClass]="{'historiccoverageoffset': clazz.currentHistoricCoverage !== null}"
Expand All @@ -79,7 +79,7 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
<div class="currenthistory {{getClassName(clazz.branchCoverage, clazz.currentHistoricCoverage.bcq)}}">
{{clazz.branchCoveragePercentage}}
</div>
<div [title]="clazz.currentHistoricCoverage.et">{{clazz.currentHistoricCoverage.bcq}}%</div>
<div [title]="clazz.currentHistoricCoverage.et + ': ' + clazz.currentHistoricCoverage.branchCoverageRatioText">{{clazz.currentHistoricCoverage.bcq}}%</div>
</ng-container>
<ng-container *ngIf="clazz.currentHistoricCoverage === null">
{{clazz.branchCoveragePercentage}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { CodeElementViewModel } from "./viewmodels/codelement-viewmodel.class";
<th class="right">{{element.uncoveredLines}}</th>
<th class="right">{{element.coverableLines}}</th>
<th class="right">{{element.totalLines}}</th>
<th class="right">{{element.coveragePercentage}}</th>
<th class="right" [title]="element.coverageRatioText">{{element.coveragePercentage}}</th>
<th class="right"><coverage-bar [percentage]="element.coverage"></coverage-bar></th>
<th class="right" *ngIf="branchCoverageAvailable">{{element.branchCoveragePercentage}}</th>
<th class="right" *ngIf="branchCoverageAvailable" [title]="element.branchCoverageRatioText">{{element.branchCoveragePercentage}}</th>
<th class="right" *ngIf="branchCoverageAvailable">
<coverage-bar [percentage]="element.branchCoverage"></coverage-bar>
</th>`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class HistoricCoverage {
/*
* The branchCoverageQuota.
* The execution time.
*/
et: string = "";

Expand Down Expand Up @@ -43,4 +43,32 @@ export class HistoricCoverage {
* The branchCoverageQuota.
*/
bcq: number;

constructor(hc: HistoricCoverage) {
this.et = hc.et;
this.cl = hc.cl;
this.ucl = hc.ucl;
this.cal = hc.cal;
this.tl = hc.tl;
this.lcq = hc.lcq;
this.cb = hc.cb;
this.tb = hc.tb;
this.bcq = hc.bcq;
}

get coverageRatioText(): string {
if (this.tl === 0) {
return "-";
}

return this.cl + "/" + this.cal;
}

get branchCoverageRatioText(): string {
if (this.tb === 0) {
return "-";
}

return this.cb + "/" + this.tb;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export class ClassViewModel extends ElementBase {

this.lineCoverageHistory = clazz.lch;
this.branchCoverageHistory = clazz.bch;
this.historicCoverages = clazz.hc;

clazz.hc.forEach(element => {
this.historicCoverages.push(new HistoricCoverage(element))
});
}

get coverage(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ export abstract class ElementBase {
return this.coverage + "%";
}

get coverageRatioText(): string {
if (this.coverableLines === 0) {
return "-";
}

return this.coveredLines + "/" + this.coverableLines;
}

get branchCoverage(): number {
if (this.totalBranches === 0) {
return NaN;
}

return Helper.roundNumber(100 * this.coveredBranches / this.totalBranches, 1);
}

get branchCoveragePercentage(): string {
if (this.totalBranches === 0) {
return "";
Expand All @@ -43,6 +50,14 @@ export abstract class ElementBase {
return this.branchCoverage + "%";
}

get branchCoverageRatioText(): string {
if (this.totalBranches === 0) {
return "-";
}

return this.coveredBranches + "/" + this.totalBranches;
}

abstract visible(filter: string, historicCoverageFilter: string): boolean;

abstract updateCurrentHistoricCoverage(historyComparisionDate: string): void;
Expand Down
4 changes: 4 additions & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ For further details take a look at LICENSE.txt.

CHANGELOG

4.6.3.0

* New: #364: Added tooltips to show coverage as ratio

4.6.2.0

* New: Clover: Added classfilter support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1024,14 +1024,15 @@ public void SummaryAssembly(Assembly assembly, bool branchCoverageAvailable)
this.reportTextWriter.Write("<th class=\"right\">{0}</th>", assembly.TotalLines.GetValueOrDefault());
this.reportTextWriter.Write(
"<th title=\"{0}\" class=\"right\">{1}</th>",
assembly.CoverageQuota.HasValue ? CoverageType.LineCoverage.ToString() : string.Empty,
assembly.CoverageQuota.HasValue ? $"{CoverageType.LineCoverage}: {assembly.CoveredLines}/{assembly.CoverableLines}" : string.Empty,
assembly.CoverageQuota.HasValue ? assembly.CoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
this.reportTextWriter.Write("<th>{0}</th>", CreateCoverageTable(assembly.CoverageQuota));

if (branchCoverageAvailable)
{
this.reportTextWriter.Write(
"<th class=\"right\">{0}</th>",
"<th class=\"right\" title=\"{0}\">{1}</th>",
assembly.BranchCoverageQuota.HasValue ? $"{assembly.CoveredBranches}/{assembly.TotalBranches}" : "-",
assembly.BranchCoverageQuota.HasValue ? assembly.BranchCoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
this.reportTextWriter.Write("<th>{0}</th>", CreateCoverageTable(assembly.BranchCoverageQuota));
}
Expand Down Expand Up @@ -1070,14 +1071,15 @@ public void SummaryClass(Class @class, bool branchCoverageAvailable)
this.reportTextWriter.Write("<td class=\"right\">{0}</td>", @class.TotalLines.GetValueOrDefault());
this.reportTextWriter.Write(
"<td title=\"{0}\" class=\"right\">{1}</td>",
@class.CoverageType,
@class.CoverageQuota.HasValue ? $"{@class.CoverageType}: {@class.CoveredLines}/{@class.CoverableLines}" : @class.CoverageType.ToString(),
@class.CoverageQuota.HasValue ? @class.CoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
this.reportTextWriter.Write("<td>{0}</td>", CreateCoverageTable(@class.CoverageQuota));

if (branchCoverageAvailable)
{
this.reportTextWriter.Write(
"<td class=\"right\">{0}</td>",
"<td class=\"right\" title=\"{0}\">{1}</td>",
@class.BranchCoverageQuota.HasValue ? $"{@class.CoveredBranches}/{@class.TotalBranches}" : "-",
@class.BranchCoverageQuota.HasValue ? @class.BranchCoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "%" : string.Empty);
this.reportTextWriter.Write("<td>{0}</td>", CreateCoverageTable(@class.BranchCoverageQuota));
}
Expand Down

Large diffs are not rendered by default.

0 comments on commit b41fce9

Please sign in to comment.