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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `Fail_Build_If_HQRM_Tests_Failed` now fails the build when the Pester run
reports failed blocks or failed containers (for example a discovery failure
such as an empty `-ForEach`), not only when `FailedCount` is greater than zero.
Such container/discovery failures leave `FailedCount` at `0`, so the previous
gate let them pass as a green build. The task now gates on the Pester `Result`
property, matching the check already used in `Invoke_HQRM_Tests`.
- Added tag `AllowSuppressMessageAttribute` to test `Should not suppress the required rule` to allow usage of `SuppressMessageAttribute` [#135](https://github.com/dsccommunity/DscResource.Test/issues/135).

## [0.19.0] - 2026-01-23
Expand Down
14 changes: 13 additions & 1 deletion source/tasks/Fail_Build_If_HQRM_Tests_Failed.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ task Fail_Build_If_HQRM_Tests_Failed {
{
$DscTestObject = Import-Clixml -Path $DscTestResultObjectClixml -ErrorAction 'Stop'

Assert-Build -Condition ($DscTestObject.FailedCount -eq 0) -Message ('Failed {0} tests. Aborting Build.' -f $DscTestObject.FailedCount)
<#
A discovery/container failure (for example an empty -ForEach, or a
parse error in a test file) does not increase FailedCount. It is
reported through FailedContainersCount/FailedBlocksCount and the
overall Result. Gating on FailedCount alone therefore lets such
failures slip through as a green build. Gate on Result instead, which
already accounts for failed tests, blocks and containers. This mirrors
the check already used in the Invoke_HQRM_Tests task.
#>
$assertMessage = "Pester result was '{0}'. Failed {1} test(s), {2} block(s) and {3} container(s). Aborting Build." -f
$DscTestObject.Result, $DscTestObject.FailedCount, $DscTestObject.FailedBlocksCount, $DscTestObject.FailedContainersCount

Assert-Build -Condition ($DscTestObject.Result -eq 'Passed') -Message $assertMessage
}
}