templates/t_pestertest.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
$PesterFileContent = @"
`$here = (Split-Path -Parent `$MyInvocation.MyCommand.Path).Replace((Join-Path "Tests" <scope>), (Join-Path <module> <scope>)) `$sut = (Split-Path -Leaf `$MyInvocation.MyCommand.Path).Replace(".Tests.", ".") . (Join-Path `$here `$sut) # To make test runable from project root, and from test directory itself. Do quick validation. `$testsPath = Join-Path "Tests" "<scope>" if ((Get-Location).Path -match [Regex]::Escape(`$testsPath)) { `$psmPath = (Resolve-Path "..\..\<module>\<module>.psm1").Path } else { `$psmPath = (Resolve-Path ".\<module>\<module>.psm1").Path } Import-Module `$psmPath -Force -NoClobber InModuleScope "<module>" { Describe "<name>" { } } "@ |