From 99e59c0c09d69f45fd89ede329dad4f83f049c7e Mon Sep 17 00:00:00 2001 From: nohwnd Date: Wed, 1 Jul 2026 23:42:14 +0200 Subject: [PATCH] Also fail on Pester block/container failures, not just failed tests In Pester 5 a run has three independent failure counts. Gating only on FailedCount misses FailedBlocksCount (BeforeAll/AfterAll) and FailedContainersCount (files that fail to discover/load), so a failing BeforeAll or an unloadable test file passes the build green. This adds those counts to the gate. Generated with AI (GitHub Copilot CLI). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- templates/PSFTests/pester.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/PSFTests/pester.ps1 b/templates/PSFTests/pester.ps1 index 8e32bf1..dd65623 100644 --- a/templates/PSFTests/pester.ps1 +++ b/templates/PSFTests/pester.ps1 @@ -53,7 +53,7 @@ if ($TestGeneral) foreach ($result in $results) { $totalRun += $result.TotalCount - $totalFailed += $result.FailedCount + $totalFailed += ($result.FailedCount + $result.FailedBlocksCount + $result.FailedContainersCount) $result.Tests | Where-Object Result -ne 'Passed' | ForEach-Object { $testresults += [pscustomobject]@{ Block = $_.Block @@ -87,7 +87,7 @@ if ($TestFunctions) foreach ($result in $results) { $totalRun += $result.TotalCount - $totalFailed += $result.FailedCount + $totalFailed += ($result.FailedCount + $result.FailedBlocksCount + $result.FailedContainersCount) $result.Tests | Where-Object Result -ne 'Passed' | ForEach-Object { $testresults += [pscustomobject]@{ Block = $_.Block