Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Last active January 20, 2019 07:46
Show Gist options
  • Save nohwnd/3438693993a29e0cf178ca9adbdfdc73 to your computer and use it in GitHub Desktop.
Save nohwnd/3438693993a29e0cf178ca9adbdfdc73 to your computer and use it in GitHub Desktop.
Discovery in Pester v5 does not run everything twice
Get-Module Pester | Remove-Module
Import-Module ./Pester.psd1
$sb = {
Add-Dependency {
Start-Sleep -Seconds 10
}
Describe "integration test" {
BeforeAll {
Start-Sleep -Seconds 10
}
It "test 1" {
Start-Sleep -Seconds 10
}
It "test 2" {
Start-Sleep -Seconds 10
}
}
}
$ss = $ExecutionContext.SessionState
# invoking internal pester function
# because the Find function is not
# published (yet)
(Measure-Command {
&(Get-Module Pester) {
param ($SessionState, $ScriptBlock)
$container = New-BlockContainerObject -ScriptBlock $ScriptBlock
Find-Test -BlockContainer $container -SessionState $SessionState
} -SessionState $ss -ScriptBlock $sb
}).TotalMilliseconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment