diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cd8dfc..b9f1906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `$PSBPreference.Docs.AlphabeticParamsOrder` - `$PSBPreference.Docs.ExcludeDontShow` - `$PSBPreference.Docs.UseFullTypeName` +- The `$PSBPreference` variable now supports the following Pester test + configuration options: + - `$PSBPreference.Test.SkipRemainingOnFailure` can be set to **None**, + **Run**, **Container** and **Block**. The default value is **None**. + - `$PSBPreference.Test.OutputVerbosity` can be set to **None**, **Normal**, + **Detailed**, and **Diagnostic**. The default value is **Detailed**. ## [0.7.1] 2025-04-01 diff --git a/PowerShellBuild/IB.tasks.ps1 b/PowerShellBuild/IB.tasks.ps1 index ed60d9c..e9d2d98 100644 --- a/PowerShellBuild/IB.tasks.ps1 +++ b/PowerShellBuild/IB.tasks.ps1 @@ -99,6 +99,8 @@ task Pester -If (. $pesterPreReqs) Build,{ CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFormat ImportModule = $PSBPreference.Test.ImportModule + SkipRemainingOnFailure = $PSBPreference.Test.SkipRemainingOnFailure + OutputVerbosity = $PSBPreference.Test.OutputVerbosity } Test-PSBuildPester @pesterParams } diff --git a/PowerShellBuild/Public/Test-PSBuildPester.ps1 b/PowerShellBuild/Public/Test-PSBuildPester.ps1 index 58ebfa4..9297971 100644 --- a/PowerShellBuild/Public/Test-PSBuildPester.ps1 +++ b/PowerShellBuild/Public/Test-PSBuildPester.ps1 @@ -26,6 +26,10 @@ function Test-PSBuildPester { Code coverage result output format. Currently, only 'JaCoCo' is supported by Pester. .PARAMETER ImportModule Import module from OutDir prior to running Pester tests. + .PARAMETER SkipRemainingOnFailure + Skip remaining tests after failure for selected scope. Options are None, Run, Container and Block. Default: None. + .PARAMETER OutputVerbosity + The verbosity of output, options are None, Normal, Detailed and Diagnostic. Default is Detailed. .EXAMPLE PS> Test-PSBuildPester -Path ./tests -ModuleName Mymodule -OutputPath ./out/testResults.xml @@ -54,7 +58,13 @@ function Test-PSBuildPester { [string]$CodeCoverageOutputFileFormat = 'JaCoCo', - [switch]$ImportModule + [switch]$ImportModule, + + [ValidateSet('None', 'Run', 'Container', 'Block')] + [string]$SkipRemainingOnFailure = 'None', + + [ValidateSet('None', 'Normal', 'Detailed', 'Diagnostic')] + [string]$OutputVerbosity = 'Detailed' ) if (-not (Get-Module -Name Pester)) { @@ -76,8 +86,9 @@ function Test-PSBuildPester { Import-Module Pester -MinimumVersion 5.0.0 $configuration = [PesterConfiguration]::Default - $configuration.Output.Verbosity = 'Detailed' + $configuration.Output.Verbosity = $OutputVerbosity $configuration.Run.PassThru = $true + $configuration.Run.SkipRemainingOnFailure = $SkipRemainingOnFailure $configuration.TestResult.Enabled = -not [string]::IsNullOrEmpty($OutputPath) $configuration.TestResult.OutputPath = $OutputPath $configuration.TestResult.OutputFormat = $OutputFormat diff --git a/PowerShellBuild/build.properties.ps1 b/PowerShellBuild/build.properties.ps1 index 4bf554b..4934bc2 100644 --- a/PowerShellBuild/build.properties.ps1 +++ b/PowerShellBuild/build.properties.ps1 @@ -97,6 +97,12 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul # The code coverage output format to use OutputFileFormat = 'JaCoCo' } + + # Skip remaining tests after failure for selected scope. Options are None, Run, Container and Block. Default: None. + SkipRemainingOnFailure = 'None' + + # Set verbosity of output. Options are None, Normal, Detailed and Diagnostic. Default: Detailed. + OutputVerbosity = 'Detailed' } Help = @{ # Path to updatable help CAB diff --git a/PowerShellBuild/psakeFile.ps1 b/PowerShellBuild/psakeFile.ps1 index 82173bd..ea53c07 100644 --- a/PowerShellBuild/psakeFile.ps1 +++ b/PowerShellBuild/psakeFile.ps1 @@ -105,6 +105,8 @@ Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $peste CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFileFormat ImportModule = $PSBPreference.Test.ImportModule + SkipRemainingOnFailure = $PSBPreference.Test.SkipRemainingOnFailure + OutputVerbosity = $PSBPreference.Test.OutputVerbosity } Test-PSBuildPester @pesterParams } -description 'Execute Pester tests' diff --git a/README.md b/README.md index 36499b6..b736273 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ match your environment. | $PSBPreference.Test.CodeCoverage.OutputFile | `coverage.xml` | Output file path (relative to Pester test directory) where Pester will save code coverage results to | | $PSBPreference.Test.CodeCoverage.OutputFileFormat | `$null` | Test output format to use when saving Pester code coverage results | | $PSBPreference.Test.ImportModule | `$false` | Import module from output directory prior to running Pester tests | +| $PSBPreference.Test.SkipRemainingOnFailure | `None` | Skip remaining tests after failure for selected scope. Options are None, Run, Container and Block. | +| $PSBPreference.Test.OutputVerbosity | `Detailed` | Set verbosity of output. Options are None, Normal, Detailed and Diagnostic. | | $PSBPreference.Help.UpdatableHelpOutDir | `$OutDir/UpdatableHelp` | Output directory to store update module help (CAB) | | $PSBPreference.Help.DefaultLocale | `(Get-UICulture).Name` | Default locale used for help generation | | $PSBPreference.Help.ConvertReadMeToAboutHelp | `$false` | Convert project readme into the module about file |