Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Fixed

- [**#133**](https://github.com/psake/PowerShellBuild/pull/133)
`Test-PSBuildPester` now fails the build when a Pester run fails for any
reason, not only when individual tests fail. Previously the function gated
only on `FailedCount`, so a `BeforeAll`/`AfterAll` that threw or a test file
that errored during discovery left the count at zero and the build passed
despite tests never running. The gate now checks the run's aggregate
`Result` property, which Pester derives from all failure categories.
Companion to [#128](https://github.com/psake/PowerShellBuild/pull/128),
which fixes the same gap in this repository's own build file.

## [0.8.1] 2026-06-03

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion PowerShellBuild/Public/Test-PSBuildPester.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ function Test-PSBuildPester {

$testResult = Invoke-Pester -Configuration $configuration -Verbose:$VerbosePreference

if ($testResult.FailedCount -gt 0) {
# Gate on the run's aggregate result rather than FailedCount alone. A failed
# BeforeAll/AfterAll or a container that errors during discovery leaves
# FailedCount at 0, but Pester still marks the overall Result as 'Failed'.
if ($testResult.Result -eq 'Failed') {
throw $LocalizedData.PesterTestsFailed
}

Expand Down
4 changes: 3 additions & 1 deletion psakeFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@

$testResults = Invoke-Pester -Configuration $pesterConfiguration

if (($testResults.FailedCount + $testResults.FailedBlocksCount + $testResults.FailedContainersCount) -gt 0) {
# Result aggregates every failure category (failed tests, blocks, containers),
# matching the gate in Test-PSBuildPester.
if ($testResults.Result -eq 'Failed') {
$testResults | Format-List
Write-Error -Message 'One or more Pester tests failed. Build cannot continue!'
}
Expand All @@ -69,7 +71,7 @@

# Commented out rather than removed to allow easy use in future
# Generate Invoke-Build tasks from Psake tasks
# $psakePath = [IO.Path]::Combine($settings.ModuleOutDir, 'psakefile.ps1')

Check warning on line 74 in psakeFile.ps1

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (psakefile) Suggestions: (pagefile, planefile, pageFile, Pagefile, planeFile)
# $ibPath = [IO.Path]::Combine($settings.ModuleOutDir, 'IB.tasks.ps1')
# & .\Build\Convert-PSAke.ps1 $psakePath | Out-File -Encoding UTF8 $ibPath
}
Expand Down
Loading