Skip to content

Also fail on Pester block/container failures (not just failed tests) - #207

Merged
SamErde merged 1 commit into
SamErde:mainfrom
nohwnd:fix/pester5-count-blocks-containers
Jul 2, 2026
Merged

Also fail on Pester block/container failures (not just failed tests)#207
SamErde merged 1 commit into
SamErde:mainfrom
nohwnd:fix/pester5-count-blocks-containers

Conversation

@nohwnd

@nohwnd nohwnd commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

⚠️ This PR was generated by an AI agent (GitHub Copilot CLI). Please review accordingly.

I've been seeing this commonly across Pester 5 build scripts and I'm fixing it where it looks like it could hide real failures.

In Pester 5 a run reports three independent failure counts:

  • FailedCount — failed tests (It)
  • FailedBlocksCount — failed BeforeAll / AfterAll
  • FailedContainersCount — files that error during discovery / fail to load

Gating on only FailedCount means a BeforeAll that throws, or a test file that fails to load, leaves FailedCount = 0 and the build passes green despite real failures. Pester itself derives the overall pass/fail from the sum of all three.

This change includes all three counts in the gate. Display/log messages are left unchanged.

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>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@SamErde

SamErde commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Thanks, @nohwnd!

@SamErde
SamErde merged commit 27c7c09 into SamErde:main Jul 2, 2026
9 of 10 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the build’s Pester result gating to treat failed blocks (BeforeAll/AfterAll) and failed containers (discovery/load errors) as build failures, not just failed It tests—aligning the build outcome with Pester 5’s overall pass/fail semantics.

Changes:

  • In the Test build task, gate on FailedCount + FailedBlocksCount + FailedContainersCount.
  • In the IntegrationTest build task, gate on FailedCount + FailedBlocksCount + FailedContainersCount.

Comment on lines +355 to 356
$numberFails = ($testResults.FailedCount + $testResults.FailedBlocksCount + $testResults.FailedContainersCount)
Assert-Build($numberFails -eq 0) ('Failed "{0}" unit tests.' -f $numberFails)
Comment on lines +604 to 605
$numberFails = ($testResults.FailedCount + $testResults.FailedBlocksCount + $testResults.FailedContainersCount)
Assert-Build($numberFails -eq 0) ('Failed "{0}" unit tests.' -f $numberFails)
@SamErde

SamErde commented Jul 2, 2026

Copy link
Copy Markdown
Owner

@nohwnd, the Copilot suggestions here are legit and will matter more for some projects than others (Maester).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants