Skip to content

Instantly share code, notes, and snippets.

@gpduck
Created November 7, 2014 22:13
Show Gist options
  • Save gpduck/82cbf879260d5bed2f33 to your computer and use it in GitHub Desktop.
Save gpduck/82cbf879260d5bed2f33 to your computer and use it in GitHub Desktop.
Testing a script file in a module
function Some-Function {
}
Export-ModuleMember -Function Some-Function
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
Describe "Some-Function" {
Mock "Export-ModuleMember" -ParameterFilter { $Function -eq "Some-Function" } -Verifiable
#I've moved this down here, is this OK?
. "$here\$sut"
Context "Other Tests" {
It "has other functionality" {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment