-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixture parameters to Describe was mistakenly marked as Mandatory in a recent commit. Instead of that, its previous behavior was to be optional, but to throw a more user-friendly error message if it's not specified. Added tests to make sure this doesn't happen again, and also applied the same logic / tests to the Context command.
- Loading branch information
Showing
4 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Set-StrictMode -Version Latest | ||
|
||
Describe 'Testing Context' { | ||
It 'Has a non-mandatory fixture parameter which throws the proper error message if missing' { | ||
$command = Get-Command Context -Module Pester | ||
$command | Should Not Be $null | ||
|
||
$parameter = $command.Parameters['Fixture'] | ||
$parameter | Should Not Be $null | ||
|
||
$attribute = $parameter.Attributes | Where-Object { $_.TypeId -eq [System.Management.Automation.ParameterAttribute] } | ||
$isMandatory = $null -ne $attribute -and $attribute.Mandatory | ||
|
||
$isMandatory | Should Be $false | ||
|
||
{ Context Bogus } | Should Throw 'No test script block is provided' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Set-StrictMode -Version Latest | ||
|
||
Describe 'Testing Describe' { | ||
It 'Has a non-mandatory fixture parameter which throws the proper error message if missing' { | ||
$command = Get-Command Describe -Module Pester | ||
$command | Should Not Be $null | ||
|
||
$parameter = $command.Parameters['Fixture'] | ||
$parameter | Should Not Be $null | ||
|
||
$attribute = $parameter.Attributes | Where-Object { $_.TypeId -eq [System.Management.Automation.ParameterAttribute] } | ||
$isMandatory = $null -ne $attribute -and $attribute.Mandatory | ||
|
||
$isMandatory | Should Be $false | ||
|
||
{ Describe Bogus } | Should Throw 'No test script block is provided' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters