Skip to content

Commit

Permalink
#364: Added addtional columns for branch coverage in summary
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Aug 29, 2020
1 parent 6cc5e3b commit 66c3405
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 3 deletions.
Binary file modified docs/resources/SampleReports.zip
Binary file not shown.
Expand Up @@ -69,6 +69,28 @@ import { ClassViewModel } from "./viewmodels/class-viewmodel.class";
</ng-container>
</td>
<td class="right"><coverage-bar [percentage]="clazz.coverage"></coverage-bar></td>
<td class="right" *ngIf="branchCoverageAvailable">
<ng-container *ngIf="clazz.currentHistoricCoverage !== null">
<div class="currenthistory {{getClassName(clazz.coveredBranches, clazz.currentHistoricCoverage.cb)}}">
{{clazz.coveredBranches}}
</div>
<div [title]="clazz.currentHistoricCoverage.et">
{{clazz.currentHistoricCoverage.cb}}
</div>
</ng-container>
<ng-container *ngIf="clazz.currentHistoricCoverage === null">
{{clazz.coveredBranches}}
</ng-container>
</td>
<td class="right" *ngIf="branchCoverageAvailable">
<ng-container *ngIf="clazz.currentHistoricCoverage !== null">
<div class="currenthistory">{{clazz.totalBranches}}</div>
<div [title]="clazz.currentHistoricCoverage.et">{{clazz.currentHistoricCoverage.tb}}</div>
</ng-container>
<ng-container *ngIf="clazz.currentHistoricCoverage === null">
{{clazz.totalBranches}}
</ng-container>
</td>
<td class="right" *ngIf="branchCoverageAvailable" [title]="clazz.branchCoverageRatioText">
<div coverage-history-chart [historicCoverages]="clazz.branchCoverageHistory"
*ngIf="clazz.branchCoverageHistory.length > 1"
Expand Down
Expand Up @@ -14,6 +14,8 @@ import { CodeElementViewModel } from "./viewmodels/codelement-viewmodel.class";
<th class="right">{{element.totalLines}}</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.coveredBranches}}</th>
<th class="right" *ngIf="branchCoverageAvailable">{{element.totalBranches}}</th>
<th class="right" *ngIf="branchCoverageAvailable" [title]="element.branchCoverageRatioText">{{element.branchCoveragePercentage}}</th>
<th class="right" *ngIf="branchCoverageAvailable">
<coverage-bar [percentage]="element.branchCoverage"></coverage-bar>
Expand Down
Expand Up @@ -66,6 +66,8 @@ import { CodeElementViewModel } from "./viewmodels/codelement-viewmodel.class";
<col class="column70">
<col class="column98">
<col class="column112">
<col class="column90" *ngIf="branchCoverageAvailable">
<col class="column70" *ngIf="branchCoverageAvailable">
<col class="column98" *ngIf="branchCoverageAvailable">
<col class="column112" *ngIf="branchCoverageAvailable">
</colgroup>
Expand Down Expand Up @@ -96,6 +98,14 @@ import { CodeElementViewModel } from "./viewmodels/codelement-viewmodel.class";
[ngClass]="{'icon-up-dir_active': settings.sortBy === 'coverage' && settings.sortOrder === 'desc',
'icon-down-dir_active': settings.sortBy === 'coverage' && settings.sortOrder === 'asc',
'icon-down-dir': settings.sortBy !== 'coverage'}"></i>{{translations.coverage}}</a></th>
<th class="right"><a href="#" (click)="updateSorting('covered_branches', $event)"><i class="icon-down-dir"
[ngClass]="{'icon-up-dir_active': settings.sortBy === 'covered_branches' && settings.sortOrder === 'desc',
'icon-down-dir_active': settings.sortBy === 'covered_branches' && settings.sortOrder === 'asc',
'icon-down-dir': settings.sortBy !== 'covered_branches'}"></i>{{translations.covered}}</a></th>
<th class="right"><a href="#" (click)="updateSorting('total_branches', $event)"><i class="icon-down-dir"
[ngClass]="{'icon-up-dir_active': settings.sortBy === 'total_branches' && settings.sortOrder === 'desc',
'icon-down-dir_active': settings.sortBy === 'total_branches' && settings.sortOrder === 'asc',
'icon-down-dir': settings.sortBy !== 'total_branches'}"></i>{{translations.total}}</a></th>
<th class="center" colspan="2" *ngIf="branchCoverageAvailable">
<a href="#" (click)="updateSorting('branchcoverage', $event)"><i class="icon-down-dir"
[ngClass]="{'icon-up-dir_active': settings.sortBy === 'branchcoverage' && settings.sortOrder === 'desc',
Expand Down
Expand Up @@ -203,6 +203,18 @@ export class CodeElementViewModel extends ElementBase {
return left.coverage < right.coverage ? smaller : bigger;
}
});
} else if (sortBy === "covered_branches") {
this.classes.sort(function (left: ClassViewModel, right: ClassViewModel): number {
return left.coveredBranches === right.coveredBranches ?
0
: (left.coveredBranches < right.coveredBranches ? smaller : bigger);
});
} else if (sortBy === "total_branches") {
this.classes.sort(function (left: ClassViewModel, right: ClassViewModel): number {
return left.totalBranches === right.totalBranches ?
0
: (left.totalBranches < right.totalBranches ? smaller : bigger);
});
} else if (sortBy === "branchcoverage") {
this.classes.sort(function (left: ClassViewModel, right: ClassViewModel): number {
if (left.branchCoverage === right.branchCoverage) {
Expand Down
1 change: 1 addition & 0 deletions src/Readme.txt
Expand Up @@ -65,6 +65,7 @@ CHANGELOG

4.6.5.0

* New: #364: Added addtional columns for branch coverage in summary
* New: #367: Cobertura: Added support for cycolmatic complexity
* Fix: #363: Fixed OpenCover file handling (not unique tracked methods)
* Fix: #371: Fixed order of metrics
Expand Down
Expand Up @@ -365,6 +365,8 @@ public void BeginSummaryTable(bool branchCoverageAvailable)

if (branchCoverageAvailable)
{
this.reportTextWriter.WriteLine("<col class=\"column90\" />");
this.reportTextWriter.WriteLine("<col class=\"column70\" />");
this.reportTextWriter.WriteLine("<col class=\"column60\" />");
this.reportTextWriter.WriteLine("<col class=\"column112\" />");
}
Expand All @@ -383,7 +385,9 @@ public void BeginSummaryTable(bool branchCoverageAvailable)
if (branchCoverageAvailable)
{
this.reportTextWriter.Write(
"<th class=\"center\" colspan=\"2\">{0}</th>",
"<th class=\"right\">{0}</th><th class=\"right\">{1}</th><th class=\"center\" colspan=\"2\">{2}</th>",
WebUtility.HtmlEncode(ReportResources.Covered),
WebUtility.HtmlEncode(ReportResources.Total),
WebUtility.HtmlEncode(ReportResources.BranchCoverage));
}

Expand Down Expand Up @@ -1057,6 +1061,8 @@ public void SummaryAssembly(Assembly assembly, bool branchCoverageAvailable)

if (branchCoverageAvailable)
{
this.reportTextWriter.Write("<th class=\"right\">{0}</th>", assembly.CoveredBranches);
this.reportTextWriter.Write("<th class=\"right\">{0}</th>", assembly.TotalBranches);
this.reportTextWriter.Write(
"<th class=\"right\" title=\"{0}\">{1}</th>",
assembly.BranchCoverageQuota.HasValue ? $"{assembly.CoveredBranches}/{assembly.TotalBranches}" : "-",
Expand Down Expand Up @@ -1104,6 +1110,8 @@ public void SummaryClass(Class @class, bool branchCoverageAvailable)

if (branchCoverageAvailable)
{
this.reportTextWriter.Write("<td class=\"right\">{0}</td>", @class.CoveredBranches);
this.reportTextWriter.Write("<td class=\"right\">{0}</td>", @class.TotalBranches);
this.reportTextWriter.Write(
"<td class=\"right\" title=\"{0}\">{1}</td>",
@class.BranchCoverageQuota.HasValue ? $"{@class.CoveredBranches}/{@class.TotalBranches}" : "-",
Expand Down
Expand Up @@ -12,7 +12,7 @@ h1 a.button { color: #000; background-color: #bebebe; margin: -5px 0 0 10px; pad
h1 a.button:hover { background-color: #ccc; }
h1 a.button i { position: relative; top: 1px; }

.container { margin: auto; max-width: 1500px; width: 90%; background-color: #fff; display: flex; box-shadow: 0 0 60px #7d7d7d; min-height: 100%; }
.container { margin: auto; max-width: 1650px; width: 90%; background-color: #fff; display: flex; box-shadow: 0 0 60px #7d7d7d; min-height: 100%; }
.containerleft { padding: 0 20px 20px 20px; flex: 1; }
.containerright { width: 340px; min-width: 340px; background-color: #e5e5e5; height: 100%; }
.containerrightfixed { position: fixed; padding: 0 20px 20px 20px; border-left: solid 1px #6f6f6f; width: 300px; overflow-y: auto; height: 100%; top: 0; bottom: 0; }
Expand Down

Large diffs are not rendered by default.

0 comments on commit 66c3405

Please sign in to comment.