From 7096844a319f0467c8e3b51fc46b24a5dbe09911 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Apr 2022 10:47:40 +0200 Subject: [PATCH] Fix discovery phase to fail (issue #112) (#122) --- CHANGELOG.md | 5 +++++ source/tasks/Invoke_HQRM_Tests.build.ps1 | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a3916..0084f49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated pipeline to use the latest build and pipeline files from Sampler. +### Fixed + +- Now the pipeline will fail if the Pester discovery phase fails. Prior + if discovery failed the pipeline still passed ([issue #112](https://github.com/dsccommunity/DscResource.Test/issues/112)). + ## [0.16.0] - 2021-09-11 ### Added diff --git a/source/tasks/Invoke_HQRM_Tests.build.ps1 b/source/tasks/Invoke_HQRM_Tests.build.ps1 index 2977172..2df3634 100644 --- a/source/tasks/Invoke_HQRM_Tests.build.ps1 +++ b/source/tasks/Invoke_HQRM_Tests.build.ps1 @@ -485,4 +485,13 @@ task Invoke_HQRM_Tests { $DscTestResultObjectCliXml = Join-Path -Path $DscTestOutputFolder -ChildPath "DscTestObject_$DscTestOutputFileFileName" $null = $script:testResults | Export-CliXml -Path $DscTestResultObjectCliXml -Force + + <# + Verify so that all containers (discovery phase) ran and all tests passed, + if not make sure the test pipeline correctly fails. + #> + if ($script:testResults.Result -eq 'Failed') + { + throw 'Pester reported failure. Tests did not pass.' + } }