Skip to content

Commit

Permalink
feat: include coverage % in toggle coverage code lems
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeneos committed Jan 24, 2024
1 parent 1615815 commit 7c8b5a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,16 @@ export class TestCoverageLensProvider implements vscode.CodeLensProvider<TestCov
class TestCoverageCodeLens extends vscode.CodeLens {
constructor(range: vscode.Range, public readonly className: string, coverageDetails: ApexTestCoverage) {
super(range, {
title: 'Test Coverage',
title: `Test Coverage (${TestCoverageCodeLens.getCoveragePercentage(coverageDetails)}%)`,
command: VlocodeCommand.apexToggleCoverage,
arguments: [ coverageDetails ]
});
}

static getCoveragePercentage(coverageDetails: ApexTestCoverage) {
return Math.round(
coverageDetails.coveredLines.length /
(coverageDetails.coveredLines.length + coverageDetails.uncoveredLines.length) * 100
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class ToggleApexTestCoverage extends CommandBase {
}

const coverageDetails = await this.getCoverage(apexClassName);
if (!coverageDetails) {
if (!coverageDetails || !coverageDetails.coveredLines.length && !coverageDetails.uncoveredLines.length) {
void vscode.window.showWarningMessage(`No test coverage collected for ${apexClassName}.`);
return;
}
Expand Down

0 comments on commit 7c8b5a2

Please sign in to comment.