Skip to content

Commit

Permalink
Remove Pending status (#2457)
Browse files Browse the repository at this point in the history
* Remove Pending status

* Update src/functions/Output.ps1

Co-authored-by: Frode Flaten <3436158+fflaten@users.noreply.github.com>

* Remove output types

* Fix tests

* Line

---------

Co-authored-by: Frode Flaten <3436158+fflaten@users.noreply.github.com>
  • Loading branch information
nohwnd and fflaten authored May 18, 2024
1 parent f4c0f3d commit c92e864
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 263 deletions.
30 changes: 5 additions & 25 deletions src/Main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,6 @@ function Get-AssertionDynamicParams {
return $script:AssertionDynamicParams
}

function Has-Flag {
param
(
[Parameter(Mandatory = $true)]
[Pester.OutputTypes]
$Setting,
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[Pester.OutputTypes]
$Value
)

0 -ne ($Setting -band $Value)
}

function Invoke-Pester {
<#
.SYNOPSIS
Expand Down Expand Up @@ -331,7 +317,7 @@ function Invoke-Pester {
EnableExit parameter to return an exit code that contains the number of failed
tests.
You can also use the Strict parameter to fail all pending and skipped tests.
You can also use the Strict parameter to fail all skipped tests.
This feature is ideal for build systems and other processes that require success
on every test.
Expand Down Expand Up @@ -510,7 +496,7 @@ function Invoke-Pester {
(Deprecated v4)
Replace with ConfigurationProperty Output.Verbosity
Customizes the output Pester writes to the screen. Available options are None, Default,
Passed, Failed, Pending, Skipped, Inconclusive, Describe, Context, Summary, Header, All, Fails.
Passed, Failed, Skipped, Inconclusive, Describe, Context, Summary, Header, All, Fails.
The options can be combined to define presets.
ConfigurationProperty Output.Verbosity supports the following values:
None
Expand All @@ -535,7 +521,7 @@ function Invoke-Pester {
.PARAMETER Strict
(Deprecated v4)
Makes Pending and Skipped tests to Failed tests. Useful for continuous
Makes Skipped tests to Failed tests. Useful for continuous
integration where you need to make sure all tests passed.
.PARAMETER TagFilter
Expand Down Expand Up @@ -663,7 +649,7 @@ function Invoke-Pester {
[object]$PesterOption,

[Parameter(ParameterSetName = "Legacy", DontShow)] # Legacy set for v4 compatibility during migration - deprecated
[Pester.OutputTypes]$Show = 'All'
[String] $Show = 'All'
)
begin {
$start = [DateTime]::Now
Expand Down Expand Up @@ -1074,7 +1060,7 @@ function Convert-PesterLegacyParameterSet ($BoundParameters) {
if ($null -ne $Show) {
# most used v4 options are adapted, and it also takes v5 options to be able to migrate gradually
# without switching the whole param set just to get Diagnostic output
# {None | Default | Passed | Failed | Pending | Skipped | Inconclusive | Describe | Context | Summary | Header | Fails | All}
# {None | Default | Passed | Failed | Skipped | Inconclusive | Describe | Context | Summary | Header | Fails | All}
$verbosity = switch ($Show) {
'All' { 'Detailed' }
'Default' { 'Detailed' }
Expand Down Expand Up @@ -1308,7 +1294,6 @@ function Set-PesterStatistics($Node) {
$Node.PassedCount += $action.PassedCount
$Node.FailedCount += $action.FailedCount
$Node.SkippedCount += $action.SkippedCount
$Node.PendingCount += $action.PendingCount
$Node.InconclusiveCount += $action.InconclusiveCount
}
elseif ($action.Type -eq 'TestCase') {
Expand All @@ -1324,9 +1309,6 @@ function Set-PesterStatistics($Node) {
Skipped {
$Node.SkippedCount++; break;
}
Pending {
$Node.PendingCount++; break;
}
Inconclusive {
$Node.InconclusiveCount++; break;
}
Expand Down Expand Up @@ -1393,7 +1375,6 @@ function ConvertTo-Pester4Result {
PassedCount = 0
FailedCount = 0
SkippedCount = 0
PendingCount = 0
InconclusiveCount = 0
Time = [TimeSpan]::Zero
TestResult = [System.Collections.Generic.List[object]]@()
Expand Down Expand Up @@ -1463,7 +1444,6 @@ function ConvertTo-Pester4Result {
}
}
$legacyResult.TotalCount = $legacyResult.TestResult.Count
$legacyResult.PendingCount = 0
$legacyResult.Time = $PesterResult.Duration

$legacyResult
Expand Down
8 changes: 1 addition & 7 deletions src/Pester.Runtime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ function Invoke-TestItem {

$Test.FrameworkData.Runtime.ExecutionStep = 'Finished'

if (@('PesterTestSkipped', 'PesterTestInconclusive', 'PesterTestPending') -contains $Result.ErrorRecord.FullyQualifiedErrorId) {
if (@('PesterTestSkipped', 'PesterTestInconclusive') -contains $Result.ErrorRecord.FullyQualifiedErrorId) {
#Same logic as when setting a test block to skip
if ($PesterPreference.Debug.WriteDebugMessages.Value) {
$path = $Test.Path -join '.'
Expand All @@ -693,12 +693,6 @@ function Invoke-TestItem {
}
else {
$Test.Skipped = $true

# Pending test is still considered a skipped, we don't have a special category for it.
# Mark the run to show deprecation message.
if ('PesterTestPending' -eq $Result.ErrorRecord.FullyQualifiedErrorId) {
$test.Block.Root.FrameworkData['ShowPendingDeprecation'] = $true
}
}
}
else {
Expand Down
2 changes: 0 additions & 2 deletions src/csharp/Pester/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ public Block()
public Hashtable FrameworkData { get; set; } = new Hashtable();
public Hashtable PluginData { get; set; } = new Hashtable();

public int PendingCount { get; set; }
public int InconclusiveCount { get; set; }

public bool OwnPassed { get; set; }
public int OwnTotalCount { get; set; }
public int OwnPassedCount { get; set; }
public int OwnFailedCount { get; set; }
public int OwnSkippedCount { get; set; }
public int OwnPendingCount { get; set; }
public int OwnNotRunCount { get; set; }
public int OwnInconclusiveCount { get; set; }

Expand Down
21 changes: 0 additions & 21 deletions src/csharp/Pester/OutputTypes.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/functions/Coverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ function Get-JaCoCoReportXml {

$isGutters = "CoverageGutters" -eq $Format

if ($null -eq $CoverageReport -or ($pester.Show -eq [Pester.OutputTypes]::None) -or $CoverageReport.NumberOfCommandsAnalyzed -eq 0) {
if ($null -eq $CoverageReport -or ('None' -eq $pester.Show) -or $CoverageReport.NumberOfCommandsAnalyzed -eq 0) {
return [string]::Empty
}

Expand Down
15 changes: 0 additions & 15 deletions src/functions/It.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
AAA pattern (Arrange-Act-Assert), this typically holds the
Assert.
.PARAMETER Pending
Use this parameter to explicitly mark the test as work-in-progress/not implemented/pending when you
need to distinguish a test that fails because it is not finished yet from a tests
that fail as a result of changes being made in the code base. An empty test, that is a
test that contains nothing except whitespace or comments is marked as Pending by default.
.PARAMETER Skip
Use this parameter to explicitly mark the test to be skipped. This is preferable to temporarily
commenting out a test, because the test remains listed in the output.
Expand Down Expand Up @@ -133,9 +127,6 @@

[String[]] $Tag,

[Parameter(ParameterSetName = 'Pending')]
[Switch] $Pending,

[Parameter(ParameterSetName = 'Skip')]
[Switch] $Skip

Expand All @@ -146,12 +137,6 @@
)

$Focus = $false
if ($PSBoundParameters.ContainsKey('Pending')) {
$PSBoundParameters.Remove('Pending')

$Skip = $Pending
# $SkipBecause = "This test is pending."
}

if ($null -eq $Test) {
if ($Name.Contains("`n")) {
Expand Down
39 changes: 2 additions & 37 deletions src/functions/Output.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ $script:ReportStrings = DATA {
TestsPassed = 'Tests Passed: {0}, '
TestsFailed = 'Failed: {0}, '
TestsSkipped = 'Skipped: {0}, '
TestsPending = 'Pending: {0}, '
TestsInconclusive = 'Inconclusive: {0}, '
TestsNotRun = 'NotRun: {0}'
}
Expand All @@ -46,8 +45,6 @@ $script:ReportTheme = DATA {
FailDetail = 'Red'
Skipped = 'Yellow'
SkippedTime = 'DarkGray'
Pending = 'Gray'
PendingTime = 'DarkGray'
NotRun = 'Gray'
NotRunTime = 'DarkGray'
Total = 'Gray'
Expand Down Expand Up @@ -235,7 +232,7 @@ function ConvertTo-PesterResult {
return $testResult
}

if (@('PesterAssertionFailed', 'PesterTestSkipped', 'PesterTestInconclusive', 'PesterTestPending') -contains $ErrorRecord.FullyQualifiedErrorID) {
if (@('PesterAssertionFailed', 'PesterTestSkipped', 'PesterTestInconclusive') -contains $ErrorRecord.FullyQualifiedErrorID) {
# we use TargetObject to pass structured information about the error.
$details = $ErrorRecord.TargetObject

Expand All @@ -249,9 +246,6 @@ function ConvertTo-PesterResult {
PesterTestInconclusive {
$testResult.Result = 'Inconclusive'; break;
}
PesterTestPending {
$testResult.Result = 'Pending'; break;
}
PesterTestSkipped {
$testResult.Result = 'Skipped'; break;
}
Expand All @@ -277,7 +271,6 @@ function Write-PesterReport {
[Parameter(mandatory = $true, valueFromPipeline = $true)]
[Pester.Run] $RunResult
)
# if(-not ($PesterState.Show | Has-Flag Summary)) { return }

Write-PesterHostMessage ($ReportStrings.Timing -f (Get-HumanTime ($RunResult.Duration))) -Foreground $ReportTheme.Foreground

Expand Down Expand Up @@ -309,12 +302,6 @@ function Write-PesterReport {
$ReportTheme.Information
}

# $Pending = if ($RunResult.PendingCount -gt 0) {
# $ReportTheme.Pending
# }
# else {
# $ReportTheme.Information
# }
$Inconclusive = if ($RunResult.InconclusiveCount -gt 0) {
$ReportTheme.Inconclusive
}
Expand Down Expand Up @@ -360,18 +347,6 @@ function Write-PesterReport {
Write-PesterHostMessage ('Container failed: {0}' -f $RunResult.FailedContainersCount) -Foreground $ReportTheme.Fail
Write-PesterHostMessage ($cs -join [Environment]::NewLine) -Foreground $ReportTheme.Fail
}
# & $SafeCommands['Write-Host'] ($ReportStrings.TestsPending -f $RunResult.PendingCount) -Foreground $Pending -NoNewLine
# & $SafeCommands['Write-Host'] ($ReportStrings.TestsInconclusive -f $RunResult.InconclusiveCount) -Foreground $Inconclusive
# }

$rootFrameworkData = @($RunResult.Containers.Blocks.Root.FrameworkData)
foreach ($frameworkData in $rootFrameworkData) {
if ($null -ne $frameworkData -and $frameworkData['ShowPendingDeprecation']) {
Write-PesterHostMessage '**DEPRECATED**: The -Pending parameter of Set-ItResult is deprecated. The parameter will be removed in a future version of Pester.' -ForegroundColor $ReportTheme.Warning
# Show it only once.
break
}
}
}

function Write-CoverageReport {
Expand Down Expand Up @@ -713,7 +688,7 @@ function Get-WriteScreenPlugin ($Verbosity) {
$margin = $ReportStrings.Margin * ($level)
$error_margin = $margin + $ReportStrings.Margin
$out = $_test.ExpandedName
if (-not $_test.Skip -and @('PesterTestSkipped', 'PesterTestInconclusive', 'PesterTestPending') -contains $Result.ErrorRecord.FullyQualifiedErrorId) {
if (-not $_test.Skip -and @('PesterTestSkipped', 'PesterTestInconclusive') -contains $Result.ErrorRecord.FullyQualifiedErrorId) {
$skippedMessage = [String]$_Test.ErrorRecord
[String]$out += " $skippedMessage"
}
Expand Down Expand Up @@ -789,16 +764,6 @@ function Get-WriteScreenPlugin ($Verbosity) {
break
}

Pending {
if ($PesterPreference.Output.Verbosity.Value -in 'Detailed', 'Diagnostic') {
$because = if ($_test.FailureMessage) { ", because $($_test.FailureMessage)" } else { $null }
Write-PesterHostMessage -ForegroundColor $ReportTheme.Pending "$margin[?] $out" -NoNewLine
Write-PesterHostMessage -ForegroundColor $ReportTheme.Pending ", is pending$because" -NoNewLine
Write-PesterHostMessage -ForegroundColor $ReportTheme.PendingTime " $humanTime"
}
break
}

Inconclusive {
if ($PesterPreference.Output.Verbosity.Value -in 'Detailed', 'Diagnostic') {
$because = if ($_test.FailureMessage) { ", because $($_test.FailureMessage)" } else { $null }
Expand Down
19 changes: 3 additions & 16 deletions src/functions/Set-ItResult.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@
Sometimes a test shouldn't be executed, sometimes the condition cannot be evaluated.
By default such tests would typically fail and produce a big red message.
Using Set-ItResult it is possible to set the result from the inside of the It script
block to either inconclusive, pending or skipped.
As of Pester 5, there is no "Inconclusive" or "Pending" test state, so all tests will now go to state skipped,
however the test result notes will include information about being inconclusive or testing to keep this command
backwards compatible
block to either inconclusive, or skipped.
.PARAMETER Inconclusive
Sets the test result to inconclusive. Cannot be used at the same time as -Pending or -Skipped
.PARAMETER Pending
**DEPRECATED** Sets the test result to pending. Cannot be used at the same time as -Inconclusive or -Skipped
Sets the test result to inconclusive. Cannot be used at the same time as -Skipped
.PARAMETER Skipped
Sets the test result to skipped. Cannot be used at the same time as -Inconclusive or -Pending
Sets the test result to skipped. Cannot be used at the same time as -Inconclusive.
.PARAMETER Because
Similarly to failing tests, skipped and inconclusive tests should have reason. It allows
Expand Down Expand Up @@ -54,7 +47,6 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $false, ParameterSetName = "Inconclusive")][switch]$Inconclusive,
[Parameter(Mandatory = $false, ParameterSetName = "Pending")][switch]$Pending,
[Parameter(Mandatory = $false, ParameterSetName = "Skipped")][switch]$Skipped,
[string]$Because
)
Expand All @@ -81,11 +73,6 @@
[String]$message = "is inconclusive"
break
}
'Pending' {
[String]$errorId = 'PesterTestPending'
[String]$message = "is pending"
break
}
'Skipped' {
[String]$errorId = 'PesterTestSkipped'
[String]$message = "is skipped"
Expand Down
21 changes: 0 additions & 21 deletions src/functions/TestResults.NUnit25.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ function Get-ParameterizedTestSuiteInfo {
PassedCount = 0
FailedCount = 0
SkippedCount = 0
PendingCount = 0
InconclusiveCount = 0
}

Expand All @@ -175,9 +174,6 @@ function Get-ParameterizedTestSuiteInfo {
Skipped {
$node.SkippedCount++; break;
}
Pending {
$node.PendingCount++; break;
}
Inconclusive {
$node.InconclusiveCount++; break;
}
Expand Down Expand Up @@ -330,20 +326,6 @@ function Write-NUnitTestCaseAttributes {
break
}

Pending {
$XmlWriter.WriteAttributeString('result', 'Inconclusive')
$XmlWriter.WriteAttributeString('executed', 'True')

# TODO: This doesn't work, FailureMessage comes from Get-ErrorForXmlReport which isn't called
if ($TestResult.FailureMessage) {
$XmlWriter.WriteStartElement('reason')
$xmlWriter.WriteElementString('message', $TestResult.FailureMessage)
$XmlWriter.WriteEndElement() # Close reason tag
}

break
}

Inconclusive {
$XmlWriter.WriteAttributeString('result', 'Inconclusive')
$XmlWriter.WriteAttributeString('executed', 'True')
Expand Down Expand Up @@ -384,9 +366,6 @@ function Get-GroupResult ($InputObject) {
if ($InputObject.SkippedCount -gt 0) {
return 'Ignored'
}
if ($InputObject.PendingCount -gt 0) {
return 'Inconclusive'
}
if ($InputObject.InconclusiveCount -gt 0) {
return 'Inconclusive'
}
Expand Down
Loading

0 comments on commit c92e864

Please sign in to comment.