Skip to content

Commit

Permalink
Add cheaper check for deprecation, and a test, remove INCONCLUSIVE fr…
Browse files Browse the repository at this point in the history
…om message
  • Loading branch information
nohwnd committed Apr 10, 2024
1 parent 066ca5d commit 9d80eb5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/Pester.Runtime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ 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
5 changes: 2 additions & 3 deletions src/functions/Output.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,8 @@ function Write-PesterReport {
# & $SafeCommands['Write-Host'] ($ReportStrings.TestsInconclusive -f $RunResult.InconclusiveCount) -Foreground $Inconclusive
# }

if ($RunResult.Tests.ErrorRecord.FullyQualifiedErrorID -contains 'PesterTestPending') {
Write-PesterHostMessage ''
Write-PesterHostMessage '**DEPRECATED**: The Set-ItResult -Pending parameter is deprecated. It will be removed in a future version of Pester.' -ForegroundColor $ReportTheme.Warning
if ($RunResult.Containers.Blocks.Root.FrameworkData['ShowPendingDeprecation'] -eq $true) {
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
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/functions/Set-ItResult.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
```powershell
Describe "Example" {
It "Inconclusive test" {
Set-ItResult -Inconclusive -Because "we want it to be inconclusice"
Set-ItResult -Inconclusive -Because "we want it to be inconclusive"
}
It "Skipped test" {
Set-ItResult -Skipped -Because "we want it to be skipped"
Expand All @@ -42,7 +42,7 @@
```
Describing Example
[?] Inconclusive test is inconclusive, because INCONCLUSIVE: we want it to be inconclusice 35ms (32ms|3ms)
[?] Inconclusive test is inconclusive, because we want it to be inconclusive 35ms (32ms|3ms)
[!] Skipped test is skipped, because we want it to be skipped 3ms (2ms|1ms)
Tests completed in 78ms
Tests Passed: 0, Failed: 0, Skipped: 1, Inconclusive: 1, NotRun: 0
Expand All @@ -63,10 +63,6 @@

$result = $PSCmdlet.ParameterSetName

if ($Result -ne 'Skipped') {
[String]$Because = if ($Because) { $Result.ToUpper(), $Because -join ': ' } else { $Result.ToUpper() }
}

switch ($null) {
$File {
[String]$File = $MyInvocation.ScriptName
Expand Down
21 changes: 21 additions & 0 deletions tst/Pester.RSpec.Output.ts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,25 @@ 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
}
}
}

0 comments on commit 9d80eb5

Please sign in to comment.