Skip to content

Commit 63340de

Browse files
authored
Feature: Add support for additional Pester test configuration options (#81)
* Add `SkipRemainingOnFailure` and `OutputVerbosity` to `$PSBPreference.Test` with default values of `None` and `Detailed` respectively
1 parent 946bbe9 commit 63340de

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- `$PSBPreference.Docs.AlphabeticParamsOrder`
1515
- `$PSBPreference.Docs.ExcludeDontShow`
1616
- `$PSBPreference.Docs.UseFullTypeName`
17+
- The `$PSBPreference` variable now supports the following Pester test
18+
configuration options:
19+
- `$PSBPreference.Test.SkipRemainingOnFailure` can be set to **None**,
20+
**Run**, **Container** and **Block**. The default value is **None**.
21+
- `$PSBPreference.Test.OutputVerbosity` can be set to **None**, **Normal**,
22+
**Detailed**, and **Diagnostic**. The default value is **Detailed**.
1723

1824
## [0.7.1] 2025-04-01
1925

PowerShellBuild/IB.tasks.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ task Pester -If (. $pesterPreReqs) Build,{
9999
CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile
100100
CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFormat
101101
ImportModule = $PSBPreference.Test.ImportModule
102+
SkipRemainingOnFailure = $PSBPreference.Test.SkipRemainingOnFailure
103+
OutputVerbosity = $PSBPreference.Test.OutputVerbosity
102104
}
103105
Test-PSBuildPester @pesterParams
104106
}

PowerShellBuild/Public/Test-PSBuildPester.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ function Test-PSBuildPester {
2626
Code coverage result output format. Currently, only 'JaCoCo' is supported by Pester.
2727
.PARAMETER ImportModule
2828
Import module from OutDir prior to running Pester tests.
29+
.PARAMETER SkipRemainingOnFailure
30+
Skip remaining tests after failure for selected scope. Options are None, Run, Container and Block. Default: None.
31+
.PARAMETER OutputVerbosity
32+
The verbosity of output, options are None, Normal, Detailed and Diagnostic. Default is Detailed.
2933
.EXAMPLE
3034
PS> Test-PSBuildPester -Path ./tests -ModuleName Mymodule -OutputPath ./out/testResults.xml
3135
@@ -54,7 +58,13 @@ function Test-PSBuildPester {
5458

5559
[string]$CodeCoverageOutputFileFormat = 'JaCoCo',
5660

57-
[switch]$ImportModule
61+
[switch]$ImportModule,
62+
63+
[ValidateSet('None', 'Run', 'Container', 'Block')]
64+
[string]$SkipRemainingOnFailure = 'None',
65+
66+
[ValidateSet('None', 'Normal', 'Detailed', 'Diagnostic')]
67+
[string]$OutputVerbosity = 'Detailed'
5868
)
5969

6070
if (-not (Get-Module -Name Pester)) {
@@ -76,8 +86,9 @@ function Test-PSBuildPester {
7686

7787
Import-Module Pester -MinimumVersion 5.0.0
7888
$configuration = [PesterConfiguration]::Default
79-
$configuration.Output.Verbosity = 'Detailed'
89+
$configuration.Output.Verbosity = $OutputVerbosity
8090
$configuration.Run.PassThru = $true
91+
$configuration.Run.SkipRemainingOnFailure = $SkipRemainingOnFailure
8192
$configuration.TestResult.Enabled = -not [string]::IsNullOrEmpty($OutputPath)
8293
$configuration.TestResult.OutputPath = $OutputPath
8394
$configuration.TestResult.OutputFormat = $OutputFormat

PowerShellBuild/build.properties.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
9797
# The code coverage output format to use
9898
OutputFileFormat = 'JaCoCo'
9999
}
100+
101+
# Skip remaining tests after failure for selected scope. Options are None, Run, Container and Block. Default: None.
102+
SkipRemainingOnFailure = 'None'
103+
104+
# Set verbosity of output. Options are None, Normal, Detailed and Diagnostic. Default: Detailed.
105+
OutputVerbosity = 'Detailed'
100106
}
101107
Help = @{
102108
# Path to updatable help CAB

PowerShellBuild/psakeFile.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $peste
105105
CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile
106106
CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFileFormat
107107
ImportModule = $PSBPreference.Test.ImportModule
108+
SkipRemainingOnFailure = $PSBPreference.Test.SkipRemainingOnFailure
109+
OutputVerbosity = $PSBPreference.Test.OutputVerbosity
108110
}
109111
Test-PSBuildPester @pesterParams
110112
} -description 'Execute Pester tests'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ match your environment.
115115
| $PSBPreference.Test.CodeCoverage.OutputFile | `coverage.xml` | Output file path (relative to Pester test directory) where Pester will save code coverage results to |
116116
| $PSBPreference.Test.CodeCoverage.OutputFileFormat | `$null` | Test output format to use when saving Pester code coverage results |
117117
| $PSBPreference.Test.ImportModule | `$false` | Import module from output directory prior to running Pester tests |
118+
| $PSBPreference.Test.SkipRemainingOnFailure | `None` | Skip remaining tests after failure for selected scope. Options are None, Run, Container and Block. |
119+
| $PSBPreference.Test.OutputVerbosity | `Detailed` | Set verbosity of output. Options are None, Normal, Detailed and Diagnostic. |
118120
| $PSBPreference.Help.UpdatableHelpOutDir | `$OutDir/UpdatableHelp` | Output directory to store update module help (CAB) |
119121
| $PSBPreference.Help.DefaultLocale | `(Get-UICulture).Name` | Default locale used for help generation |
120122
| $PSBPreference.Help.ConvertReadMeToAboutHelp | `$false` | Convert project readme into the module about file |

0 commit comments

Comments
 (0)