Last active
July 28, 2017 08:56
-
-
Save OCram85/859bc85101879cbb3cf609d583b171f4 to your computer and use it in GitHub Desktop.
Pester Test Header
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
#region HEADER | |
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$RepoRoot = (Get-GitDirectory).replace('\.git', '') | |
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' | |
$sut = $sut -replace "\d{2}`_", '' | |
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName | |
# Skip try loading the source file if it doesn't exists. | |
If ($suthome.Length -gt 0) { | |
. $suthome | |
} | |
Else { | |
Write-Warning ("Could not find source file {0}" -f $sut) | |
} | |
# load additional functions defined in the repository. Replace the expression <FunctionName>. | |
# . (Get-ChildItem -Path $RepoRoot -Filter "<Function-Name>.ps1" -Recurse).FullName | |
#endregion HEADER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
posh-git
module to find the git repository root directory.^(\d{2})_<SourceFileName>.Tests.ps1$
Invoke-SomeTasks.ps1
01_Invoke-SomeTasks.Tests.ps1