From c92e86471ea16d0b95fb66c128b0517c51ab0b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Sat, 18 May 2024 14:11:44 +0200 Subject: [PATCH] Remove Pending status (#2457) * 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> --- src/Main.ps1 | 30 ++------ src/Pester.Runtime.ps1 | 8 +-- src/csharp/Pester/Block.cs | 2 - src/csharp/Pester/OutputTypes.cs | 21 ------ src/functions/Coverage.ps1 | 2 +- src/functions/It.ps1 | 15 ---- src/functions/Output.ps1 | 39 +---------- src/functions/Set-ItResult.ps1 | 19 +---- src/functions/TestResults.NUnit25.ps1 | 21 ------ src/functions/TestResults.NUnit3.ps1 | 2 - tst/Pester.RSpec.Output.ts.ps1 | 21 ------ tst/functions/Output.Tests.ps1 | 70 ++----------------- tst/functions/Set-ItResult.Tests.ps1 | 9 --- tst/functions/SetupTeardown.Tests.ps1 | 2 +- .../TestsRunningInCleanRunspace.Tests.ps1 | 30 +++----- 15 files changed, 28 insertions(+), 263 deletions(-) delete mode 100644 src/csharp/Pester/OutputTypes.cs diff --git a/src/Main.ps1 b/src/Main.ps1 index 14b9a82a1..871388b89 100644 --- a/src/Main.ps1 +++ b/src/Main.ps1 @@ -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 @@ -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. @@ -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 @@ -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 @@ -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 @@ -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' } @@ -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') { @@ -1324,9 +1309,6 @@ function Set-PesterStatistics($Node) { Skipped { $Node.SkippedCount++; break; } - Pending { - $Node.PendingCount++; break; - } Inconclusive { $Node.InconclusiveCount++; break; } @@ -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]]@() @@ -1463,7 +1444,6 @@ function ConvertTo-Pester4Result { } } $legacyResult.TotalCount = $legacyResult.TestResult.Count - $legacyResult.PendingCount = 0 $legacyResult.Time = $PesterResult.Duration $legacyResult diff --git a/src/Pester.Runtime.ps1 b/src/Pester.Runtime.ps1 index d7db4e8fd..4074ba1d9 100644 --- a/src/Pester.Runtime.ps1 +++ b/src/Pester.Runtime.ps1 @@ -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 '.' @@ -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 { diff --git a/src/csharp/Pester/Block.cs b/src/csharp/Pester/Block.cs index a794a4dff..3146107d8 100644 --- a/src/csharp/Pester/Block.cs +++ b/src/csharp/Pester/Block.cs @@ -83,7 +83,6 @@ 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; } @@ -91,7 +90,6 @@ public Block() 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; } diff --git a/src/csharp/Pester/OutputTypes.cs b/src/csharp/Pester/OutputTypes.cs deleted file mode 100644 index 3bec81b9b..000000000 --- a/src/csharp/Pester/OutputTypes.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -namespace Pester -{ - [Flags] - public enum OutputTypes - { - None = 0, - 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 - } -} diff --git a/src/functions/Coverage.ps1 b/src/functions/Coverage.ps1 index 439ec650a..fbe981366 100644 --- a/src/functions/Coverage.ps1 +++ b/src/functions/Coverage.ps1 @@ -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 } diff --git a/src/functions/It.ps1 b/src/functions/It.ps1 index 08caaf022..bd69fd0a6 100644 --- a/src/functions/It.ps1 +++ b/src/functions/It.ps1 @@ -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. @@ -133,9 +127,6 @@ [String[]] $Tag, - [Parameter(ParameterSetName = 'Pending')] - [Switch] $Pending, - [Parameter(ParameterSetName = 'Skip')] [Switch] $Skip @@ -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")) { diff --git a/src/functions/Output.ps1 b/src/functions/Output.ps1 index 48dedbd14..d9df42923 100644 --- a/src/functions/Output.ps1 +++ b/src/functions/Output.ps1 @@ -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}' } @@ -46,8 +45,6 @@ $script:ReportTheme = DATA { FailDetail = 'Red' Skipped = 'Yellow' SkippedTime = 'DarkGray' - Pending = 'Gray' - PendingTime = 'DarkGray' NotRun = 'Gray' NotRunTime = 'DarkGray' Total = 'Gray' @@ -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 @@ -249,9 +246,6 @@ function ConvertTo-PesterResult { PesterTestInconclusive { $testResult.Result = 'Inconclusive'; break; } - PesterTestPending { - $testResult.Result = 'Pending'; break; - } PesterTestSkipped { $testResult.Result = 'Skipped'; break; } @@ -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 @@ -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 } @@ -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 { @@ -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" } @@ -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 } diff --git a/src/functions/Set-ItResult.ps1 b/src/functions/Set-ItResult.ps1 index 1d3e97a04..6dfc8da33 100644 --- a/src/functions/Set-ItResult.ps1 +++ b/src/functions/Set-ItResult.ps1 @@ -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 @@ -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 ) @@ -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" diff --git a/src/functions/TestResults.NUnit25.ps1 b/src/functions/TestResults.NUnit25.ps1 index 6a7af0506..aa0eec17a 100644 --- a/src/functions/TestResults.NUnit25.ps1 +++ b/src/functions/TestResults.NUnit25.ps1 @@ -159,7 +159,6 @@ function Get-ParameterizedTestSuiteInfo { PassedCount = 0 FailedCount = 0 SkippedCount = 0 - PendingCount = 0 InconclusiveCount = 0 } @@ -175,9 +174,6 @@ function Get-ParameterizedTestSuiteInfo { Skipped { $node.SkippedCount++; break; } - Pending { - $node.PendingCount++; break; - } Inconclusive { $node.InconclusiveCount++; break; } @@ -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') @@ -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' } diff --git a/src/functions/TestResults.NUnit3.ps1 b/src/functions/TestResults.NUnit3.ps1 index c97fbd8c6..687e20e00 100644 --- a/src/functions/TestResults.NUnit3.ps1 +++ b/src/functions/TestResults.NUnit3.ps1 @@ -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 } } @@ -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 } diff --git a/tst/Pester.RSpec.Output.ts.ps1 b/tst/Pester.RSpec.Output.ts.ps1 index 92a72c106..f900f8d3a 100644 --- a/tst/Pester.RSpec.Output.ts.ps1 +++ b/tst/Pester.RSpec.Output.ts.ps1 @@ -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 - } - } } diff --git a/tst/functions/Output.Tests.ps1 b/tst/functions/Output.Tests.ps1 index 84e7528cc..3b54bedc3 100644 --- a/tst/functions/Output.Tests.ps1 +++ b/tst/functions/Output.Tests.ps1 @@ -4,64 +4,6 @@ BeforeAll { $PSDefaultParameterValues = @{ 'Should:ErrorAction' = 'Stop' } } -InModuleScope -ModuleName Pester -ScriptBlock { - Describe 'Has-Flag' -Fixture { - It 'Returns true when setting and value are the same' { - $setting = [Pester.OutputTypes]::Passed - $value = [Pester.OutputTypes]::Passed - - $value | Has-Flag $setting | Should -Be $true - } - - It 'Returns false when setting and value are the different' { - $setting = [Pester.OutputTypes]::Passed - $value = [Pester.OutputTypes]::Failed - - $value | Has-Flag $setting | Should -Be $false - } - - It 'Returns true when setting contains value' { - $setting = [Pester.OutputTypes]::Passed -bor [Pester.OutputTypes]::Failed - $value = [Pester.OutputTypes]::Passed - - $value | Has-Flag $setting | Should -Be $true - } - - It 'Returns false when setting does not contain the value' { - $setting = [Pester.OutputTypes]::Passed -bor [Pester.OutputTypes]::Failed - $value = [Pester.OutputTypes]::Summary - - $value | Has-Flag $setting | Should -Be $false - } - - It 'Returns true when at least one setting is contained in value' { - $setting = [Pester.OutputTypes]::Passed -bor [Pester.OutputTypes]::Failed - $value = [Pester.OutputTypes]::Summary -bor [Pester.OutputTypes]::Failed - - $value | Has-Flag $setting | Should -Be $true - } - - It 'Returns false when none of settings is contained in value' { - $setting = [Pester.OutputTypes]::Passed -bor [Pester.OutputTypes]::Failed - $value = [Pester.OutputTypes]::Summary -bor [Pester.OutputTypes]::Describe - - $value | Has-Flag $setting | Should -Be $false - } - } - - Describe 'Default OutputTypes' -Fixture { - It 'Fails output type contains all except passed' { - $expected = [Pester.OutputTypes]'Default, Failed, Pending, Skipped, Inconclusive, Describe, Context, Summary, Header' - [Pester.OutputTypes]::Fails | Should -Be $expected - } - - It 'All output type contains all flags' { - $expected = [Pester.OutputTypes]'Default, Passed, Failed, Pending, Skipped, Inconclusive, Describe, Context, Summary, Header' - [Pester.OutputTypes]::All | Should -Be $expected - } - } -} - BeforeAll { $thisScriptRegex = [regex]::Escape((Get-Item $PSCommandPath).FullName) } @@ -244,7 +186,7 @@ InModuleScope -ModuleName Pester -ScriptBlock { $r.Message.Count | Should -be 6 $r.Trace[0] | Should -match "'One' | Should -be 'Two'" - $r.Trace[1] | Should -be "at , ${PSCommandPath}:230" + $r.Trace[1] | Should -be "at , ${PSCommandPath}:172" $r.Trace.Count | Should -be 2 } # TODO: should fails with a very weird error, probably has something to do with dynamic params... @@ -323,7 +265,7 @@ InModuleScope -ModuleName Pester -ScriptBlock { $r.Trace[0] | Should -be "at f1, ${testPath}:2" $r.Trace[1] | Should -be "at f2, ${testPath}:5" $r.Trace[2] | Should -be "at , ${testPath}:7" - $r.Trace[3] | Should -be "at , ${PSCommandPath}:306" + $r.Trace[3] | Should -be "at , ${PSCommandPath}:248" $r.Trace.Count | Should -be 4 } } @@ -334,7 +276,7 @@ InModuleScope -ModuleName Pester -ScriptBlock { $r.Trace[0] | Should -be "at f1, ${testPath}:2" $r.Trace[1] | Should -be "at f2, ${testPath}:5" $r.Trace[2] | Should -be "at , ${testPath}:7" - $r.Trace[3] | Should -be "at , ${PSCommandPath}:306" + $r.Trace[3] | Should -be "at , ${PSCommandPath}:248" $r.Trace.Count | Should -be 4 } } @@ -395,7 +337,7 @@ InModuleScope -ModuleName Pester -ScriptBlock { It 'produces correct trace line.' { if ($hasStackTrace) { $r.Trace[0] | Should -be "at , $testPath`:10" - $r.Trace[1] | Should -be "at , $PSCommandPath`:372" + $r.Trace[1] | Should -be "at , $PSCommandPath`:314" $r.Trace.Count | Should -be 2 } } @@ -404,7 +346,7 @@ InModuleScope -ModuleName Pester -ScriptBlock { It 'produces correct trace line.' { if ($hasStackTrace) { $r.Trace[0] | Should -be "at , $testPath`:10" - $r.Trace[1] | Should -be "at , $PSCommandPath`:372" + $r.Trace[1] | Should -be "at , $PSCommandPath`:314" $r.Trace.Count | Should -be 2 } } @@ -493,7 +435,7 @@ InModuleScope -ModuleName Pester -ScriptBlock { $errorMessage = Format-ErrorMessage -Err $errorRecord -StackTraceVerbosity $_ $messages = $errorMessage -split [Environment]::NewLine $messages[0] | Should -BeExactly "System.DivideByZeroException: Attempted to divide by zero." - $messages[1] | Should -BeExactly "at , ${PSCommandPath}: line 447" + $messages[1] | Should -BeExactly "at , ${PSCommandPath}: line 389" $messages.Count | Should -BeGreaterThan 1 } diff --git a/tst/functions/Set-ItResult.Tests.ps1 b/tst/functions/Set-ItResult.Tests.ps1 index d6ce83bf8..ed7f642a9 100644 --- a/tst/functions/Set-ItResult.Tests.ps1 +++ b/tst/functions/Set-ItResult.Tests.ps1 @@ -10,15 +10,6 @@ Describe "Testing Set-ItResult" { } } - It "This test should be pending" { - try { - Set-ItResult -Pending -Because "we are forcing it to pending" - } - catch { - $_.FullyQualifiedErrorID | Should -Be "PesterTestPending" - } - } - It "This test should be skipped" { try { Set-ItResult -Skipped -Because "we are forcing it to skip" diff --git a/tst/functions/SetupTeardown.Tests.ps1 b/tst/functions/SetupTeardown.Tests.ps1 index 8605fc069..864ffa0e2 100644 --- a/tst/functions/SetupTeardown.Tests.ps1 +++ b/tst/functions/SetupTeardown.Tests.ps1 @@ -116,7 +116,7 @@ Describe 'Multiple Test Case teardown blocks' { $container.Value = 'Set in the first Context AfterEach' } - It 'Performs a test in Context' { "some output to prevent the It being marked as Pending and failing because of Strict mode" } + It 'Performs a test in Context' { "some output" } It 'Executes Describe teardown blocks after Context teardown blocks' { $container.Value | Should -Be 'Set in the second Describe AfterEach' diff --git a/tst/functions/TestsRunningInCleanRunspace.Tests.ps1 b/tst/functions/TestsRunningInCleanRunspace.Tests.ps1 index 8fc1ed592..017bdb1fc 100644 --- a/tst/functions/TestsRunningInCleanRunspace.Tests.ps1 +++ b/tst/functions/TestsRunningInCleanRunspace.Tests.ps1 @@ -57,26 +57,20 @@ function Invoke-PesterInJob ($ScriptBlock, [switch] $GenerateNUnitReport, [switc } Describe "Tests running in clean runspace" { - It "It - Skip and Pending tests" { + It "It - Skip tests" { #tests to be run in different runspace using different Pester instance $TestSuite = { - Describe 'It - Skip and Pending tests' { + Describe 'It - Skip tests' { It "Skip without ScriptBlock" -skip It "Skip with empty ScriptBlock" -skip {} It "Skip with not empty ScriptBlock" -Skip { "something" } - - It "Implicit pending" {} - It "Pending without ScriptBlock" -Pending - It "Pending with empty ScriptBlock" -Pending {} - It "Pending with not empty ScriptBlock" -Pending { "something" } } } $result = Invoke-PesterInJob -ScriptBlock $TestSuite $result.SkippedCount | Should -Be 3 - $result.PendingCount | Should -Be 4 - $result.TotalCount | Should -Be 7 + $result.TotalCount | Should -Be 3 } It "It - It without ScriptBlock fails" { @@ -103,7 +97,6 @@ Describe "Tests running in clean runspace" { it "Passes" { "pass" } it "fails" { throw } it "Skipped" -Skip {} - it "Pending" -Pending {} } } @@ -111,9 +104,8 @@ Describe "Tests running in clean runspace" { $result.PassedCount | Should -Be 1 $result.FailedCount | Should -Be 1 $result.SkippedCount | Should -Be 1 - $result.PendingCount | Should -Be 1 - $result.TotalCount | Should -Be 4 + $result.TotalCount | Should -Be 3 } It 'Produces valid NUnit output when syntax errors occur in test scripts' { @@ -139,16 +131,12 @@ Describe "Tests running in clean runspace" { It "Invoke-Pester - Strict mode" { #tests to be run in different runspace using different Pester instance $TestSuite = { - Describe 'Mark skipped and pending tests as failed' { + Describe 'Mark skipped and inconclusive tests as failed' { It "skip" -Skip { $true | Should -Be $true } - It "pending" -Pending { $true | Should -Be $true } It "inconclusive forced" { Set-TestInconclusive ; $true | Should -Be $true } It 'skipped by Set-ItResult' { Set-ItResult -Skipped -Because "it is a test" } - It 'pending by Set-ItResult' { - Set-ItResult -Pending -Because "it is a test" - } It 'inconclusive by Set-ItResult' { Set-ItResult -Inconclusive -Because "it is a test" } @@ -157,9 +145,9 @@ Describe "Tests running in clean runspace" { $result = Invoke-PesterInJob -ScriptBlock $TestSuite -UseStrictPesterMode $result.PassedCount | Should Be 0 - $result.FailedCount | Should Be 6 + $result.FailedCount | Should Be 4 - $result.TotalCount | Should Be 6 + $result.TotalCount | Should Be 4 } } @@ -208,13 +196,13 @@ Describe 'Guarantee It fail on setup or teardown fail (running in clean runspace Describe 'Make sure all the tests in the suite run' { #when the previous test fails in after each and - It 'It is pending' -Pending {} + It 'It is skipped' -Skip {} } } $result = Invoke-PesterInJob -ScriptBlock $testSuite - if ($result.PendingCount -ne 1) { + if ($result.SkippedCount -ne 1) { throw "The test suite in separate runspace did not run to completion, it was likely terminated by an uncaught exception thrown in AfterEach." }