Skip to content

Commit

Permalink
Make Invoke-PSCodeHealth compatible with Pester 3.4.0 and later; fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuBuisson committed Jun 27, 2017
1 parent 7135c9d commit f64e62c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion PSCodeHealth/Private/Metrics/Get-FunctionTestCoverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ Function Get-FunctionTestCoverage {
$TestsPath = Split-Path -Path $SourcePath -Parent
}

$TestsResult = Invoke-Pester -Script $TestsPath -CodeCoverage @{ Path = $SourcePath; Function = $FunctionName } -PassThru -Show None -Verbose:$False
# Invoke-Pester didn't have the "Show" parameter prior to version 4.x
$SuppressOutput = If ((Get-Module -Name Pester).Version.Major -lt 4) { @{Quiet = $True} } Else { @{Show = 'None'} }

$TestsResult = Invoke-Pester -Script $TestsPath -CodeCoverage @{ Path = $SourcePath; Function = $FunctionName } -PassThru -Verbose:$False @SuppressOutput

If ( $TestsResult.CodeCoverage ) {
$CodeCoverage = $TestsResult.CodeCoverage
Expand Down
7 changes: 5 additions & 2 deletions PSCodeHealth/Private/New-PSCodeHealthReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ Function New-PSCodeHealthReport {
$OverallPesterParams = @{
Script = $TestsPath
CodeCoverage = $Path
Show = 'None'
PassThru = $True
Strict = $True
Verbose = $False
WarningAction = 'SilentlyContinue'
}
$TestsResult = Invoke-Pester @OverallPesterParams

# Invoke-Pester didn't have the "Show" parameter prior to version 4.x
$SuppressOutput = If ((Get-Module -Name Pester).Version.Major -lt 4) { @{Quiet = $True} } Else { @{Show = 'None'} }

$TestsResult = Invoke-Pester @OverallPesterParams @SuppressOutput
}
If ( $TestsResult.CodeCoverage ) {
$CodeCoverage = $TestsResult.CodeCoverage
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Want to know more ? Head to the full documentation :

Before using PSCodeHealth, you need :
- PowerShell 5.x
- The **[Pester](https://github.com/pester/Pester)** PowerShell module (version 4.0.x or later)
- The **[Pester](https://github.com/pester/Pester)** PowerShell module (version 3.4.0 or later)
- The **[PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer)** PowerShell module

## Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Want to know more ? Head to the full documentation :

Before using PSCodeHealth, you need :
- PowerShell 5.x
- The **[Pester](https://github.com/pester/Pester)** PowerShell module (version 4.0.x or later)
- The **[Pester](https://github.com/pester/Pester)** PowerShell module (version 3.4.0 or later)
- The **[PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer)** PowerShell module

0 comments on commit f64e62c

Please sign in to comment.