Skip to content

Instantly share code, notes, and snippets.

@Staggerlee011
Created February 28, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Staggerlee011/85514118a8880a05b6d8713cb3fbe000 to your computer and use it in GitHub Desktop.
Save Staggerlee011/85514118a8880a05b6d8713cb3fbe000 to your computer and use it in GitHub Desktop.
Pester tests which runs every script analyser rule
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