Skip to content

Commit ebd794e

Browse files
committed
Feature: Add new Pester test options to PSBPreference
* Add Test.SkipRemainingOnFailure * Add Test.OutputVerbosity
1 parent 7890486 commit ebd794e

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

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: 12 additions & 1 deletion
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)) {
@@ -78,6 +88,7 @@ function Test-PSBuildPester {
7888
$configuration = [PesterConfiguration]::Default
7989
$configuration.Output.Verbosity = 'Detailed'
8090
$configuration.Run.PassThru = $true
91+
$configuration.Run.SkipRemainingOnFailure = $FailFast.toboo
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)