Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Pending status #2457

Merged
merged 6 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/Main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,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 +510,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 +535,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 @@ -1074,7 +1074,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 +1308,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 +1323,6 @@ function Set-PesterStatistics($Node) {
Skipped {
$Node.SkippedCount++; break;
}
Pending {
$Node.PendingCount++; break;
}
Inconclusive {
$Node.InconclusiveCount++; break;
}
Expand Down Expand Up @@ -1393,7 +1389,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 +1458,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
5 changes: 2 additions & 3 deletions src/csharp/Pester/OutputTypes.cs
fflaten marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ public enum OutputTypes
Default = 1,
Passed = 2,
Failed = 4,
Pending = 8,
Skipped = 16,
Inconclusive = 32,
Describe = 64,
Context = 128,
Summary = 256,
Header = 512,
All = Default | Passed | Failed | Pending | Skipped | Inconclusive | Describe | Context | Summary | Header,
Fails = Default | Failed | Pending | Skipped | Inconclusive | Describe | Context | Summary | Header
All = Default | Passed | Failed | Skipped | Inconclusive | Describe | Context | Summary | Header,
Fails = Default | Failed | Skipped | Inconclusive | Describe | Context | Summary | Header
}
}
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
36 changes: 2 additions & 34 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 Down Expand Up @@ -309,12 +303,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 +348,8 @@ 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
# }
nohwnd marked this conversation as resolved.
Show resolved Hide resolved

$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 +691,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 +767,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
2 changes: 0 additions & 2 deletions src/functions/TestResults.NUnit3.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ function Write-NUnit3TestCaseElement {

switch ($TestResult.Result) {
Skipped { Write-NUnitReasonElement -TestResult $TestResult -XmlWriter $XmlWriter; break }
Pending { Write-NUnitReasonElement -TestResult $TestResult -XmlWriter $XmlWriter; break }
Inconclusive { Write-NUnitReasonElement -TestResult $TestResult -XmlWriter $XmlWriter; break }
Failed { Write-NUnit3FailureElement -TestResult $TestResult -XmlWriter $XmlWriter; break }
}
Expand Down Expand Up @@ -522,7 +521,6 @@ function Write-NUnit3TestCaseAttributes {
Failed { $XmlWriter.WriteAttributeString('result', 'Failed'); break }
Passed { $XmlWriter.WriteAttributeString('result', 'Passed'); break }
Skipped { $XmlWriter.WriteAttributeString('result', 'Skipped'); break }
Pending { $XmlWriter.WriteAttributeString('result', 'Inconclusive'); break }
Inconclusive { $XmlWriter.WriteAttributeString('result', 'Inconclusive'); break }
# result-attribute is required, so intentionally making xml invalid if unknown state occurs
}
Expand Down
21 changes: 0 additions & 21 deletions tst/Pester.RSpec.Output.ts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,4 @@ i -PassThru:$PassThru {
$normalOutput | Verify-Equal $writehostOutput
}
}

b 'Pending is deprecated' {
t 'Shows deprecated message when -pending is used' {
$sb = {
$container = New-PesterContainer -ScriptBlock {
Describe 'd' {
It 'i' {
Set-ItResult -Pending
}
}
}

Invoke-Pester -Container $container
}

$output = Invoke-InNewProcess -ScriptBlock $sb

$deprecated = $output | Select-String -Pattern '\*DEPRECATED\*'
@($deprecated).Count | Verify-Equal 1
}
}
}
Loading