Skip to content

Commit

Permalink
Update documentation for new 'CommandsMissed' property
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuBuisson committed Jun 14, 2017
1 parent 019aaab commit aaba200
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
8 changes: 4 additions & 4 deletions PSCodeHealth/Private/Metrics/Get-FunctionTestCoverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Function Get-FunctionTestCoverage {
.DESCRIPTION
Gets test coverage information for the specified function. This includes 2 pieces of information :
- Code coverage percentage (lines of code that are exercised by unit tests)
- Missed Commands (lines of codes or commands not being exercised by unit tests)
- Code coverage percentage (lines of code that are exercized by unit tests)
- Missed Commands (lines of codes or commands not being exercized by unit tests)
It uses Pester with its CodeCoverage parameter.
Expand Down Expand Up @@ -57,8 +57,8 @@ Function Get-FunctionTestCoverage {

# To prevent any "Attempted to divide by zero" exceptions
If ( $CommandsFound -ne 0 ) {
$CommandsExercised = $CodeCoverage.NumberOfCommandsExecuted
Write-VerboseOutput -Message "Number of commands exercised in the tests : $($CommandsExercised)"
$Commandsexercised = $CodeCoverage.NumberOfCommandsExecuted
Write-VerboseOutput -Message "Number of commands exercized in the tests : $($CommandsExercised)"
[System.Double]$CodeCoveragePerCent = [math]::Round(($CommandsExercised / $CommandsFound) * 100, 2)
}
Else {
Expand Down
33 changes: 16 additions & 17 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,22 @@ ComplexityAverage : 2
ComplexityHighest : 5
NestingDepthAverage : 1.11
NestingDepthHighest : 3
FunctionHealthRecords : {@{FunctionName=Add-CoverageInfo;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=14;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=0; Complexity=1;
MaximumNestingDepth=1}, @{FunctionName=Merge-CoverageResult;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=21;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=0; Complexity=1;
MaximumNestingDepth=0}, @{FunctionName=Get-CoverageArray;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=30;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=0; Complexity=5;
MaximumNestingDepth=3}, @{FunctionName=Format-FileCoverage;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=24;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=100; Complexity=2;
MaximumNestingDepth=1}...}
FunctionHealthRecords : {@{FunctionName=Add-CoverageInfo; FilePath=C:\coveralls\Coveralls.ps1;
LinesOfCode=14; ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=0; CommandsMissed=3; Complexity=1;
MaximumNestingDepth=1}, @{FunctionName=Merge-CoverageResult;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=21;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=0; CommandsMissed=6; Complexity=1;
MaximumNestingDepth=0}, @{FunctionName=Get-CoverageArray;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=30;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=0; CommandsMissed=18; Complexity=5;
MaximumNestingDepth=3}, @{FunctionName=Format-FileCoverage;
FilePath=C:\coveralls\Coveralls.ps1; LinesOfCode=24;
ScriptAnalyzerFindings=0; ScriptAnalyzerResultDetails=;
ContainsHelp=False; TestCoverage=100; CommandsMissed=0; Complexity=2;
MaximumNestingDepth=1}...}
```
## Viewing the per-function metrics

Expand Down
7 changes: 7 additions & 0 deletions docs/Metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ Higher is better. Good tests provide confidence that the code behaves as expecte
- Warning : less than 80
- Fail : less than 70

### CommandsMissed
The number of commands in the specified function which are not exercized by the tests.
This is the number of commands, not lines, because the code coverage feature of **Pester** uses breakpoints, which can only be triggered by commands ([Source](https://github.com/pester/Pester/wiki/Code-Coverage)).

Lower is better. Any command not exercized by tests is untested, which means any defect it may contain will not be detected. Or at best, it will only be detected at later stages of the code lifecycle (user acceptance testing, QA, or in production).
The later a defect is detected, the more expensive (in time and money) it is to fix.

### Complexity
This is the cyclomatic complexity of a given function. Cyclomatic complexity measures the number of possible execution paths through a given section of code. This is intended to evaluation code complexity.

Expand Down

0 comments on commit aaba200

Please sign in to comment.