Skip to content

Instantly share code, notes, and snippets.

@Splaxi
Last active November 2, 2018 21:31
Show Gist options
  • Save Splaxi/2a24fc3c5193089ae7047ac5b8f104db to your computer and use it in GitHub Desktop.
Save Splaxi/2a24fc3c5193089ae7047ac5b8f104db to your computer and use it in GitHub Desktop.
Generate pester tests for parametersets
$moduleName = "d365fo.tools"
#$path = "C:\GIT\GITHUB\$moduleName.Workspace\$moduleName\$moduleName"
$path = "C:\GITHUB\LocalRepository\$moduleName"
Import-Module $path -Force
$excludeCommands = @()
$commandsRaw = Get-Command -Module $moduleName
if ($excludeCommands.Count -gt 0) {
$commands = $commandsRaw | Select-String -Pattern $excludeCommands -SimpleMatch -NotMatch
} else {
$commands = $commandsRaw
}
foreach ( $commandName in $commands) {
Invoke-PSMDTemplate CommandTest -OutPath "$path\tests\functions" -Name $commandName -Force
}
Get-ChildItem -Path "$path\tests\functions" -Recurse -File | Set-PSMDEncoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment