Skip to content

Commit 4bde77a

Browse files
committed
Uson Reason instead of SkipBecause
1 parent 2af0b05 commit 4bde77a

8 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/Pester.Runtime.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function New-ParametrizedBlock {
166166
[HashTable] $FrameworkData = @{ },
167167
[Switch] $Focus,
168168
[Switch] $Skip,
169-
[String] $SkipBecause,
169+
[String] $Reason,
170170
$Data
171171
)
172172

@@ -177,7 +177,7 @@ function New-ParametrizedBlock {
177177
foreach ($d in @($Data)) {
178178
# shallow clone to give every block it's own copy
179179
$fmwData = $FrameworkData.Clone()
180-
New-Block -GroupId $groupId -Name $Name -ScriptBlock $ScriptBlock -StartLine $StartLine -Tag $Tag -FrameworkData $fmwData -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause -Data $d
180+
New-Block -GroupId $groupId -Name $Name -ScriptBlock $ScriptBlock -StartLine $StartLine -Tag $Tag -FrameworkData $fmwData -Focus:$Focus -Skip:$Skip -Reason:$Reason -Data $d
181181
}
182182
}
183183

@@ -195,7 +195,7 @@ function New-Block {
195195
[Switch] $Focus,
196196
[String] $GroupId,
197197
[Switch] $Skip,
198-
[String] $SkipBecause,
198+
[String] $Reason,
199199
$Data
200200
)
201201

@@ -234,7 +234,7 @@ function New-Block {
234234
$block.Focus = $Focus
235235
$block.GroupId = $GroupId
236236
$block.Skip = $Skip
237-
$block.SkipBecause = $SkipBecause
237+
$block.Reason = $Reason
238238
$block.Data = $Data
239239

240240
# we attach the current block to the parent, and put it to the parent
@@ -483,7 +483,7 @@ function New-Test {
483483
[String] $GroupId,
484484
[Switch] $Focus,
485485
[Switch] $Skip,
486-
[String] $SkipBecause
486+
[String] $Reason
487487
)
488488

489489
if ($PesterPreference.Debug.WriteDebugMessages.Value) {
@@ -517,7 +517,7 @@ function New-Test {
517517
$test.Tag = $Tag
518518
$test.Focus = $Focus
519519
$test.Skip = $Skip
520-
$test.SkipBecause = $SkipBecause
520+
$test.Reason = $Reason
521521
$test.Data = $Data
522522
$test.FrameworkData.Runtime.Phase = 'Discovery'
523523

@@ -692,7 +692,7 @@ function Invoke-TestItem {
692692
}
693693
else {
694694
$Test.Skipped = $true
695-
$Test.SkipBecause = $result.ErrorRecord.Exception.Message
695+
$Test.Reason = $result.ErrorRecord.Exception.Message
696696
}
697697
}
698698
else {
@@ -2126,7 +2126,7 @@ function PostProcess-DiscoveredBlock {
21262126
}
21272127

21282128
$t.Skip = $true
2129-
$t.SkipBecause = $b.SkipBecause
2129+
$t.Reason = $b.Reason
21302130
}
21312131
}
21322132
}
@@ -2554,14 +2554,14 @@ function New-ParametrizedTest () {
25542554
[object[]] $Data,
25552555
[Switch] $Focus,
25562556
[Switch] $Skip,
2557-
[String] $SkipBecause
2557+
[String] $Reason
25582558
)
25592559

25602560
# using the position of It as Id for the the test so we can join multiple testcases together, this should be unique enough because it only needs to be unique for the current block.
25612561
# TODO: Id is used by NUnit2.5 and 3 testresults to group. A better way to solve this?
25622562
$groupId = "${StartLine}:${StartColumn}"
25632563
foreach ($d in $Data) {
2564-
New-Test -GroupId $groupId -Name $Name -Tag $Tag -ScriptBlock $ScriptBlock -StartLine $StartLine -Data $d -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause
2564+
New-Test -GroupId $groupId -Name $Name -Tag $Tag -ScriptBlock $ScriptBlock -StartLine $StartLine -Data $d -Focus:$Focus -Skip:$Skip -Reason:$Reason
25652565
}
25662566
}
25672567

src/csharp/Pester/Block.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Block()
4646
public List<string> Tag { get; set; }
4747
public bool Focus { get; set; }
4848
public bool Skip { get; set; }
49-
public string SkipBecause { get; set; }
49+
public string Reason { get; set; }
5050

5151
public string ItemType { get; } = "Block";
5252

src/csharp/Pester/Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Test()
4848
public List<string> Tag { get; set; }
4949
public bool Focus { get; set; }
5050
public bool Skip { get; set; }
51-
public string SkipBecause { get; set; }
51+
public string Reason { get; set; }
5252
// IDictionary to allow users use [ordered]
5353

5454
public object Block { get; set; }

src/functions/Context.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
# [Switch] $Focus,
9191
[Switch] $Skip,
92-
[String] $SkipBecause,
92+
[String] $Reason,
9393
[Switch] $AllowNullOrEmptyForEach,
9494

9595
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'ForEach is not used in Foreach-Object loop')]
@@ -123,10 +123,10 @@
123123
return
124124
}
125125

126-
New-ParametrizedBlock -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -StartColumn $MyInvocation.OffsetInLine -Tag $Tag -FrameworkData @{ CommandUsed = 'Context'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause -Data $ForEach
126+
New-ParametrizedBlock -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -StartColumn $MyInvocation.OffsetInLine -Tag $Tag -FrameworkData @{ CommandUsed = 'Context'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -Reason:$Reason -Data $ForEach
127127
}
128128
else {
129-
New-Block -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -Tag $Tag -FrameworkData @{ CommandUsed = 'Context'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause
129+
New-Block -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -Tag $Tag -FrameworkData @{ CommandUsed = 'Context'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -Reason:$Reason
130130
}
131131
}
132132
else {

src/functions/Describe.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797

9898
# [Switch] $Focus,
9999
[Switch] $Skip,
100-
[String] $SkipBecause,
100+
[String] $Reason,
101101
[Switch] $AllowNullOrEmptyForEach,
102102

103103
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'ForEach is not used in Foreach-Object loop')]
@@ -131,10 +131,10 @@
131131
return
132132
}
133133

134-
New-ParametrizedBlock -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -StartColumn $MyInvocation.OffsetInLine -Tag $Tag -FrameworkData @{ CommandUsed = 'Describe'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause -Data $ForEach
134+
New-ParametrizedBlock -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -StartColumn $MyInvocation.OffsetInLine -Tag $Tag -FrameworkData @{ CommandUsed = 'Describe'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -Reason:$Reason -Data $ForEach
135135
}
136136
else {
137-
New-Block -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -Tag $Tag -FrameworkData @{ CommandUsed = 'Describe'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause
137+
New-Block -Name $Name -ScriptBlock $Fixture -StartLine $MyInvocation.ScriptLineNumber -Tag $Tag -FrameworkData @{ CommandUsed = 'Describe'; WrittenToScreen = $false } -Focus:$Focus -Skip:$Skip -Reason:$Reason
138138
}
139139
}
140140
else {

src/functions/It.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
[Switch] $AllowNullOrEmptyForEach,
137137

138138
[Parameter(ParameterSetName = 'Skip')]
139-
[String] $SkipBecause
139+
[String] $Reason
140140

141141
# [Switch]$Focus
142142
)
@@ -163,9 +163,9 @@
163163
return
164164
}
165165

166-
New-ParametrizedTest -Name $Name -ScriptBlock $Test -StartLine $MyInvocation.ScriptLineNumber -StartColumn $MyInvocation.OffsetInLine -Data $ForEach -Tag $Tag -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause
166+
New-ParametrizedTest -Name $Name -ScriptBlock $Test -StartLine $MyInvocation.ScriptLineNumber -StartColumn $MyInvocation.OffsetInLine -Data $ForEach -Tag $Tag -Focus:$Focus -Skip:$Skip -Reason:$Reason
167167
}
168168
else {
169-
New-Test -Name $Name -ScriptBlock $Test -StartLine $MyInvocation.ScriptLineNumber -Tag $Tag -Focus:$Focus -Skip:$Skip -SkipBecause:$SkipBecause
169+
New-Test -Name $Name -ScriptBlock $Test -StartLine $MyInvocation.ScriptLineNumber -Tag $Tag -Focus:$Focus -Skip:$Skip -Reason:$Reason
170170
}
171171
}

src/functions/TestResults.NUnit25.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ function Write-NUnitTestCaseAttributes {
317317
$XmlWriter.WriteAttributeString('result', 'Ignored')
318318
$XmlWriter.WriteAttributeString('executed', 'False')
319319

320-
if ($TestResult.SkipBecause) {
320+
if ($TestResult.Reason) {
321321
$XmlWriter.WriteStartElement('reason')
322-
$xmlWriter.WriteElementString('message', $TestResult.SkipBecause)
322+
$xmlWriter.WriteElementString('message', $TestResult.Reason)
323323
$XmlWriter.WriteEndElement() # Close reason tag
324324
}
325325

@@ -330,9 +330,9 @@ function Write-NUnitTestCaseAttributes {
330330
$XmlWriter.WriteAttributeString('result', 'Inconclusive')
331331
$XmlWriter.WriteAttributeString('executed', 'True')
332332

333-
if ($TestResult.SkipBecause) {
333+
if ($TestResult.Reason) {
334334
$XmlWriter.WriteStartElement('reason')
335-
$xmlWriter.WriteElementString('message', $TestResult.SkipBecause)
335+
$xmlWriter.WriteElementString('message', $TestResult.Reason)
336336
$XmlWriter.WriteEndElement() # Close reason tag
337337
}
338338

testing/mine.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Describe 'All The Tests' {
3131
}
3232

3333
Context 'It Reasons' {
34-
It 'Skips' -Skip -SkipBecause 'I am Skipped' {
34+
It 'Skips' -Skip -Reason 'I am Skipped' {
3535
$true | Should -BeTrue
3636
}
3737
}
@@ -42,7 +42,7 @@ Describe 'All The Tests' {
4242
}
4343
}
4444

45-
Context 'Context Reasons' -Skip -SkipBecause 'I am Skipped' {
45+
Context 'Context Reasons' -Skip -Reason 'I am Skipped' {
4646
It 'Skips' {
4747
$true | Should -BeTrue
4848
}
@@ -54,7 +54,7 @@ Describe 'All The Tests' {
5454
}
5555
}
5656

57-
Describe 'Describe Reasons' -Skip -SkipBecause 'I am Skipped' {
57+
Describe 'Describe Reasons' -Skip -Reason 'I am Skipped' {
5858
It 'Skips' {
5959
$true | Should -BeTrue
6060
}

0 commit comments

Comments
 (0)