Skip to content

Commit

Permalink
Update documentation following the addition of 'FailedTestsDetails'
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuBuisson committed Jun 18, 2017
1 parent 078c9c6 commit 3184f14
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 68 deletions.
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,24 @@ To evaluate the code quality of a single script, simply use the **`Invoke-PSCode
Specify the relative or full path of the script file via the `Path` parameter and specify the location of the tests via the `TestsPath` parameter, like so :

```powershell
C:\> Invoke-PSCodeHealth -Path '.\coveralls\Coveralls.ps1' -TestsPath '.\coveralls'
PS C:\> Invoke-PSCodeHealth -Path '.\coveralls\Coveralls.ps1' -TestsPath '.\coveralls'
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- -------------- -------------- ------------- -------------
1 9 22.33 0 0 2 39.58 %
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- ------------- ------------- ------------- -------------
1 9 22.33 0 0 2 21.88 %
```

To evaluate the code quality of all the PowerShell code in a directory, specify the relative or full path of the directory via the `Path` parameter, like so :

```powershell
C:\> Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls'
PS C:\> Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls'
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- ------------- ------------- ------------- -------------
3 9 22.33 0 0 2 21.43 %
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- -------------- -------------- ------------- -------------
3 9 22.33 0 0 2 38.78 %
```

Expand All @@ -74,18 +75,18 @@ To view the per-function information, access the `FunctionHealthRecords` propert
C:\> $HealthReport = Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls'
C:\> $HealthReport.FunctionHealthRecords
Function Name Lines of Code Complexity Contains Help Test Coverage ScriptAnalyzer
Findings
------------- ------------- ---------- ------------- ------------- -------------
Add-CoverageInfo 14 1 False 0 % 0
Merge-CoverageResult 21 1 False 0 % 0
Get-CoverageArray 30 5 False 0 % 0
Format-FileCoverage 24 2 False 100 % 0
Get-CommandsForFile 16 1 False 100 % 0
Get-GitInfo 23 2 False 0 % 0
Format-Coverage 39 3 False 0 % 0
Publish-Coverage 18 1 False 0 % 0
Get-CoveragePercentage 16 2 False 100 % 0
Function Name Lines of Code Complexity Contains Help Test Coverage ScriptAnalyzer
Findings
------------- ------------- ---------- ------------- ------------- --------------
Add-CoverageInfo 14 1 False 0 % 0
Merge-CoverageResult 21 1 False 0 % 0
Get-CoverageArray 30 5 False 94.44 % 0
Format-FileCoverage 24 2 False 100 % 0
Get-CommandsForFile 16 1 False 100 % 0
Get-GitInfo 23 2 False 0 % 0
Format-Coverage 39 3 False 0 % 0
Publish-Coverage 18 1 False 0 % 0
Get-CoveragePercentage 16 2 False 100 % 0
```

Expand Down
94 changes: 50 additions & 44 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ Specify the relative or full path of the script file via the `Path` parameter an
```powershell
C:\> Invoke-PSCodeHealth -Path '.\coveralls\Coveralls.ps1' -TestsPath '.\coveralls'
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- ------------- ------------- ------------- -------------
1 9 22.33 0 0 2 21.88 %
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- -------------- -------------- ------------- -------------
1 9 22.33 0 0 2 39.58 %
```

To evaluate the code quality of all the PowerShell code in a directory, specify the relative or full path of the directory via the `Path` parameter, like so :

```powershell
C:\> Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls'
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- ------------- ------------- ------------- -------------
3 9 22.33 0 0 2 21.43 %
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- -------------- -------------- ------------- -------------
3 9 22.33 0 0 2 38.78 %
```
## Viewing all the code metrics
Expand All @@ -29,11 +30,12 @@ The above provides a simple table to view the most important metrics at a glance
To view all the metrics, you can pipe the output of **`Invoke-PSCodeHealth`** to **`Format-List`**, like so :

```powershell
C:\> Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls' | Format-List
PS C:\> Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls' | Format-List
ReportTitle : coveralls
ReportDate : 2017-06-02 22:28:45Z
AnalyzedPath : C:\coveralls\
ReportDate : 2017-06-18 18:27:53Z
AnalyzedPath : C:\coveralls
Files : 3
Functions : 9
LinesOfCodeTotal : 201
Expand All @@ -44,12 +46,17 @@ ScriptAnalyzerWarnings : 0
ScriptAnalyzerInformation : 0
ScriptAnalyzerFindingsAverage : 0
FunctionsWithoutHelp : 9
NumberOfTests : 10
NumberOfFailedTests : 0
NumberOfPassedTests : 10
TestsPassRate : 100
TestCoverage : 21.43
CommandsMissedTotal : 77
NumberOfTests : 13
NumberOfFailedTests : 2
FailedTestsDetails : {@{File=Coveralls.Tests.ps1; Line=97; Describe=Get-CoverageArray; TestName=Should
return 2 objects with the value 1; ErrorMessage=Expected: {2}
But was: {0}}, @{File=Coveralls.Tests.ps1; Line=100; Describe=Get-CoverageArray;
TestName=Should return 0 objects with the value 0; ErrorMessage=Expected: value to
be empty but it was {1}}}
NumberOfPassedTests : 11
TestsPassRate : 84.62
TestCoverage : 38.78
CommandsMissedTotal : 60
ComplexityAverage : 2
ComplexityHighest : 5
NestingDepthAverage : 1.11
Expand All @@ -58,18 +65,16 @@ FunctionHealthRecords : {@{FunctionName=Add-CoverageInfo; FilePath=C:\co
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=;
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=94.44;
CommandsMissed=1; 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}...}
MaximumNestingDepth=1}...}
```
## Viewing the per-function metrics

Expand All @@ -79,18 +84,18 @@ To view the per-function information, access the `FunctionHealthRecords` propert
C:\> $HealthReport = Invoke-PSCodeHealth -Path '.\coveralls' -TestsPath '.\coveralls'
C:\> $HealthReport.FunctionHealthRecords
Function Name Lines of Code Complexity Contains Help Test Coverage ScriptAnalyzer
Findings
------------- ------------- ---------- ------------- ------------- -------------
Add-CoverageInfo 14 1 False 0 % 0
Merge-CoverageResult 21 1 False 0 % 0
Get-CoverageArray 30 5 False 0 % 0
Format-FileCoverage 24 2 False 100 % 0
Get-CommandsForFile 16 1 False 100 % 0
Get-GitInfo 23 2 False 0 % 0
Format-Coverage 39 3 False 0 % 0
Publish-Coverage 18 1 False 0 % 0
Get-CoveragePercentage 16 2 False 100 % 0
Function Name Lines of Code Complexity Contains Help Test Coverage ScriptAnalyzer
Findings
------------- ------------- ---------- ------------- ------------- --------------
Add-CoverageInfo 14 1 False 0 % 0
Merge-CoverageResult 21 1 False 0 % 0
Get-CoverageArray 30 5 False 94.44 % 0
Format-FileCoverage 24 2 False 100 % 0
Get-CommandsForFile 16 1 False 100 % 0
Get-GitInfo 23 2 False 0 % 0
Format-Coverage 39 3 False 0 % 0
Publish-Coverage 18 1 False 0 % 0
Get-CoveragePercentage 16 2 False 100 % 0
```
## Excluding files from the code analysis
Expand All @@ -100,8 +105,9 @@ You may want to exclude some file(s) from the code analysis because they might n
```powershell
C:\> Invoke-PSCodeHealth -Path '.\coveralls' -Exclude '*.psm1' -TestsPath '.\coveralls'
Files Functions LOC (Average) Findings Findings Complexity Test Coverage
(Total) (Average) (Average)
----- --------- ------------- -------------- -------------- -------------- -------------
2 9 22.33 0 0 2 21.88 %
Files Functions LOC (Average) Findings (Total) Findings Complexity Test Coverage
(Average) (Average)
----- --------- ------------- ---------------- ---------------- ---------------- -------------
2 9 22.33 0 0 2 39.58 %
```
4 changes: 2 additions & 2 deletions docs/Release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 2017-05-20
# 2017-06-18

- Added integration tests for PSCodeHealth report object
- Add a 'FailedTestsDetails' property to health reports

0 comments on commit 3184f14

Please sign in to comment.