Last active
January 20, 2019 07:46
-
-
Save nohwnd/3438693993a29e0cf178ca9adbdfdc73 to your computer and use it in GitHub Desktop.
Discovery in Pester v5 does not run everything twice
This file contains hidden or 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
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