pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.05k stars 469 forks source link

Option to disable old assertions #2495

Closed nohwnd closed 1 month ago

nohwnd commented 1 month ago

Checklist

Summary of the feature request

When migrating to Assert assertions I want to disable them so I know that I did not migrate some of them.

When I already migrated, I want to keep the old assertions disabled, and they should fail with informative message when used.

How should it work?

Pester option is checked in all Shoud assertions and makes them fail when the option is disabled.

nohwnd commented 1 month ago

$c.Should.DisableShouldV5 = $true

@johlju @fflaten how does this look like to you?

johlju commented 1 month ago

Looks good, but we could shorten it to Should.Disablev5?

Could also be Should.Strict = 'v6' to maybe support any future major changes 🤔 couldn't come up with anything else than Strict for that one 😊

fflaten commented 1 month ago

Looks good, but we could shorten it to Should.Disablev5?

Could also be Should.Strict = 'v6' to maybe support any future major changes 🤔 couldn't come up with anything else than Strict for that one 😊

I agree. Should.DisableV5 or something like Should.Version = 'v5','v6'

nohwnd commented 1 month ago

Or maybe Should.DisableParameterSyntax?

johlju commented 1 month ago

Or maybe Should.DisableParameterSyntax?

If it is used together with a value 'v5' otherwise it could imply that it also affects parameters of the new Should-* 🤔

johlju commented 1 month ago

We could also use Should.DisableLegacy = $true if it is the thought that the old Should are made obsolete in v6 and will be removed in a future minor or major update? That property name could be used to disable any future functionality too. 🤔

nohwnd commented 1 month ago

Okay DisableV5 it is. It is the least ambiguous option, and it is short.