Open johlju opened 4 months ago
Yes. This would be Should-MatchString
and Should-NotMatchString
, to follow the current naming convention.
I will try to do some coding this week on this, but can't promise anything.
In Pester v5 I really loved the simplicity of negating a statement:
.. | Should -Invoke Get-Process
.. | Should -Not -Invoke Get-Process
I guess the -Not
switch will no longer be used in the future? Really loved that feature though..
The v6 style is currently
# invoke is not implemented yet
.. | Should-Invoke Get-Process
.. | Should-NotInvoke Get-Process
Is that worse? As we're using standalone functions to overcome parameter set max limitation the alternative would be:
.. | Should-Invoke Get-Process
.. | Should-Invoke -Not Get-Process
.. | Should-Invoke Get-Process -Not
The parameter doesn't flow/read as well imo.
I hear what you say, it does read easier but for splatting purposes, the separate -Not
argument would be easier. I can imagine TestCases
or ForEach
where a decision is made to either call the mocked function or not.
Also for inteliSense it would be easier to use one CmdLet name instead of having to type Should-Not
.
Thanks for the explanation. Let's move this discussion to a separate issue (#2550)
Checklist
Summary of the feature request
Currently the new assertions for Pester v6 does not support regular expression matching like
Should -Match
orShould -MatchExactly
in v5. Suggest adding a commandShould-Match
andShould-NotMatch
, or possibly add a parameterRegularExpression
to the commandsShould-BeLikeString
andShould-NotBeLikeString
.How should it work?
The commands
Should-Match
andShould-NotMatch
should have the same named and positional parameters as the commandShould-NotBeLikeString
.If we reuse existing commands
Should-BeLikeString
andShould-NotBeLikeString
by adding a new switch parameter.