Skip to content

Commit

Permalink
Fix or work-around for failing tests
Browse files Browse the repository at this point in the history
Split execution of tests in `tst\functions\Add-ShouldOperator.ts.ps1` into multiple b sections, each of them reloading the Pester module, to avoid running into the more than 32 operators (parameter sets) limitation.
  • Loading branch information
Daniël te Winkel committed Oct 23, 2022
1 parent 266aa55 commit d6096fd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tst/functions/Add-ShouldOperator.ts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ Import-Module $PSScriptRoot\..\p.psm1 -DisableNameChecking
Import-Module $PSScriptRoot\..\axiom\Axiom.psm1 -DisableNameChecking

if (-not $NoBuild) { & "$PSScriptRoot\..\..\build.ps1" }
Import-Module $PSScriptRoot\..\..\bin\Pester.psd1

i -PassThru:$PassThru {
# Running as P-tests to avoid corrupting other tests if more than 32 operators (parameter sets) are defined
# https://github.com/pester/Pester/issues/1355 and https://github.com/pester/Pester/pull/2170#issuecomment-1116423527
# Running as P-tests to avoid corrupting other tests if more than 32 operators (parameter sets) are defined.
# Each b section reloads the Pester module to further avoid running into the more than 32 operators limitation for the total number of tests.
# See https://github.com/pester/Pester/issues/1355 and https://github.com/pester/Pester/pull/2170#issuecomment-1116423527.
b 'Add-ShouldOperator' {
Remove-Module Pester -Force -ErrorAction SilentlyContinue
Import-Module $PSScriptRoot\..\..\bin\Pester.psd1
${function:Add-ShouldOperator} = & (Get-Module Pester) { Get-Command Add-ShouldOperator }

t 'Adds empty HelpMessage for Should operator without synopsis' {
Expand Down Expand Up @@ -69,6 +71,13 @@ i -PassThru:$PassThru {
Add-ShouldOperator -Name MultipleAlias -Test $Function:MultipleAlias -Alias mult, multiple
}

}

b 'Add-ShouldOperator' {
Remove-Module Pester -Force -ErrorAction SilentlyContinue
Import-Module $PSScriptRoot\..\..\bin\Pester.psd1
${function:Add-ShouldOperator} = & (Get-Module Pester) { Get-Command Add-ShouldOperator }

t 'Does not allow an operator with a different test to be registered using an existing name' {
function DifferentScriptBlockA {
$true
Expand Down

0 comments on commit d6096fd

Please sign in to comment.