-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate pester 4 to 5 and fix code coverage
- Loading branch information
Romain Tiennot
committed
Aug 23, 2020
1 parent
0c3fa43
commit 2351f43
Showing
21 changed files
with
60 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
task ImportDevModule { | ||
ImportModule -Path "$Source\$ModuleName.psd1" -Force | ||
Import-BuildModule -Path "$Source\$ModuleName.psd1" -Force | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
task Pester { | ||
$requiredPercent = $Script:CodeCoveragePercent | ||
Import-Module Pester -Force | ||
$configuration = [PesterConfiguration]::Default | ||
# assing properties & discover via intellisense | ||
$configuration.Run.Path = 'Tests' | ||
$configuration.Filter.Tag = 'Build' | ||
$configuration.Run.PassThru = $true | ||
$configuration.Output.Verbosity = 'Detailed' | ||
$configuration.TestResult.Enabled = $true | ||
$configuration.TestResult.OutputFormat = 'NUnitXml' | ||
$configuration.TestResult.OutputPath = $testFile | ||
|
||
$params = @{ | ||
OutputFile = $testFile | ||
OutputFormat = 'NUnitXml' | ||
PassThru = $true | ||
Path = 'Tests' | ||
Show = 'Failed', 'Fails', 'Summary' | ||
Tag = 'Build' | ||
} | ||
if ($requiredPercent -gt 0.00) { | ||
|
||
if($requiredPercent -gt 0.00) | ||
{ | ||
$params['CodeCoverage'] = 'Output\*\*.psm1' | ||
$params['CodeCoverageOutputFile'] = 'Output\codecoverage.xml' | ||
$configuration.CodeCoverage.Enabled = $true | ||
$configuration.CodeCoverage.OutputPath = 'Output\codecoverage.xml' | ||
} | ||
|
||
$results = Invoke-Pester @params | ||
if ($results.FailedCount -gt 0) | ||
{ | ||
Write-Error -Message "Failed [$($results.FailedCount)] Pester tests." | ||
} | ||
$results = Invoke-Pester -Configuration $configuration | ||
if ($requiredPercent -gt 0.00) { | ||
|
||
if($results.codecoverage.NumberOfCommandsAnalyzed -gt 0) | ||
{ | ||
$codeCoverage = $results.codecoverage.NumberOfCommandsExecuted / $results.codecoverage.NumberOfCommandsAnalyzed | ||
if ($results.TotalCount -gt 0) { | ||
$CodeCoveragePercent = $results.TotalCount * ($results.PassedCount / 100) | ||
$codeCoverage = [math]::Round($CodeCoveragePercent,2) | ||
|
||
if($codeCoverage -lt $requiredPercent) | ||
{ | ||
Write-Error ("Failed Code Coverage [{0:P}] below {1:P}" -f $codeCoverage,$requiredPercent) | ||
if ($codeCoverage -lt [Math]::Round($requiredPercent,2)) { | ||
Write-Error ("Failed Code Coverage [{0:P}] below {1:P}" -f $codeCoverage, $requiredPercent) | ||
} | ||
} | ||
} elseif ($results.FailedCount -gt 0) { | ||
Write-Error -Message "Failed [$($results.FailedCount)] Pester tests." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ Get list of Snowflake roles | |
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
### EXEMPLE 1 | ||
``` | ||
Get-SnowSqlRole | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ Get list of Snowflake users | |
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
### EXEMPLE 1 | ||
``` | ||
Get-SnowSqlUser | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters