You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setup and teardown are not executed when they're not needed
Note: Tests skipped using Set-ItResult doesn't count as they're skipped during Run-phase (too late)
Steps To Reproduce
$sb= {
Describe 'A' {
BeforeAll {
Write-Host'Before ALL -A'
}
BeforeEach {
Write-Host'Before EACH -A'
}
AfterEach {
Write-Host'After EACH -A'
}
It 'Test 1'-Skip {
Write-Host'This is test 1'
}
Describe 'B' {
BeforeAll {
Write-Host'Before ALL -B'
}
AfterAll {
Write-Host'After ALL -B'
}
BeforeEach {
Write-Host'Before EACH -B'
}
AfterEach {
Write-Host'After EACH -B'
}
It 'Test 2'-Skip {
Write-Host'This is test 2'
}
}
AfterAll {
Write-Host'After ALL -A'
}
}
}
$conf=New-PesterConfiguration$conf.Output.Verbosity='Detailed'$conf.Run.PassThru=$true$conf.Run.ScriptBlock=$sb$r=Invoke-Pester-Configuration $conf
Output:
Pester v5.6.0-beta1Starting discovery in 1 files.Discovery found 2 tests in 35ms.Running tests.Before ALL -ADescribing A [!] Test 1 6ms (0ms|6ms)Before ALL -B Describing B [!] Test 2 3ms (0ms|3ms)After ALL -BAfter ALL -ATests completed in 77msTests Passed: 0, Failed: 0, Skipped: 2, Inconclusive: 0, NotRun: 0
Describe your environment
Pester version : 5.6.0-beta1 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.4.1
OS version : Unix 5.15.133.1
Possible Solution?
No response
The text was updated successfully, but these errors were encountered:
Related #2424. If the plugin skips remaining tests the Before-/AfterAll should not run on subsequent blocks. That means we might need to make the decision during Run or both.
I don't remember where this is done, there was some function that is recursing down to figure out all the skipped steps, and then recursing up to mark all items as skipped, when they have all children skipped.
Checklist
What is the issue?
BeforeAll
andAfterAll
are executed when all tests are skipped using-Skip
.This is a known limitation/backlog item as seen in this runtime test:
Pester/tst/Pester.Runtime.ts.ps1
Lines 1228 to 1275 in 7889a88
Expected Behavior
Setup and teardown are not executed when they're not needed
Note: Tests skipped using
Set-ItResult
doesn't count as they're skipped during Run-phase (too late)Steps To Reproduce
Output:
Describe your environment
Pester version : 5.6.0-beta1 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.4.1
OS version : Unix 5.15.133.1
Possible Solution?
No response
The text was updated successfully, but these errors were encountered: