-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
Should Throw - Needs more flexibility/power #279
Comments
👍 |
The way the
Unfortunately, that would break every single Pester script that exists today, but if I were writing the module from scratch, that's probably how I'd do it. |
To support backwords compatibility, you can map one style of #New
Function Should {
[cmdletbinding(DefaultParameterSetName="Old")]
param (
[Parameter(ParameterSetName="New")]
[Type]$Type,
[Parameter(ParameterSetName="New")]
[String]$Msg,
[Parameter(ParameterSetName="New")]
[Switch]$Throw,
[Parameter(Position=0, ParameterSetName="Old")]
[object]$Old1,
[Parameter(Position=1, ParameterSetName="Old")]
[object]$Old2,
[Parameter(Position=2, ParameterSetName="Old")]
[object]$Old3,
[Parameter(Position=3, ParameterSetName="Old")]
[object]$Old4
)
Write-Host ("ParameterSet: {0}" -f $PSCmdlet.ParameterSetName)
Write-Host "Throw: $Throw"
Write-Host "Type: $Type"
Write-Host "Msg: $Msg"
Write-Host "Old1: $Old1"
Write-Host "Old2: $Old2"
Write-Host "Old3: $Old3"
Write-Host "Old4: $Old4"
} New Syntax Test
Old Syntax Test
|
That could work. |
👍 for a more flexible |
I'm going to make this my first priority after we get a few other things merged. |
I'd also like to be able to specify exception types with the |
fyi as this issue does not seem to move very much I created a PoSH module with Pester extensions that address some of the mentioned issues: In short, with it you can do something like this:
See:
|
@dfch, can you add information about your module to the newly created wiki article Articles and other resources. @nohwnd, is it addressed in your Assert project? If yes I don't think so that issue still should be opened. @nohwnd, please add the Assert project to the list too. Thank you. |
@it-praktyk Yes it does. I should finish it and propose merging it. |
Asserting on the expected message in the exception is nice:
But what if I wanted to examine additional properties of the exception, or even the exception type? I'm forced to do this:
Proposed Syntax
The text was updated successfully, but these errors were encountered: