Created
February 28, 2017 11:41
-
-
Save Staggerlee011/85514118a8880a05b6d8713cb3fbe000 to your computer and use it in GitHub Desktop.
Pester tests which runs every script analyser rule
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
Import-Module -Name Pester | |
Import-Module -Name ScriptAnalyzer | |
Describe 'Script Analyzer Tests' { | |
Context 'Script Analyzer' { | |
$analysis = Invoke-ScriptAnalyzer -Path '.\MyScript.ps1' | |
$rules = Get-ScriptAnalyzerRule | |
foreach ($rule in $rules) { | |
It "$rule" { | |
If ($analysis.RuleName -contains $rule) { | |
$analysis | Where-Object RuleName -EQ $rule -outvariable failures | Out-Default $failures.Count | | |
Should Be 0 | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment