Closed JustinGrote closed 2 months ago
Have you seen the continue on error option for should?
@nohwnd The issue is not using multiple should in a function, that works fine with the first example.
The issue is to be able to use the truncated syntax shown in the second example, right now I cannot do that because Should doesn't output anything, so I have to keep operating against an existing resultant variable.
I think there is a proposal for this somewhere here, probably one of the issues in Better Should milestone. I was considering it, and am not against implementing it, but it was a bit limited, because only one assertion can fail. Granted you could use both this chaining and the error collecting, but when I tried it, it turned out to be rarely practical because you don't have an easy way of selecting a property from a bigger object so you will end up using variables anyway.
I think there is a proposal for this somewhere here, probably one of the issues in Better Should milestone.
Probably this https://github.com/pester/Pester/issues/1319#issuecomment-499069698 Stumbled over it when removing an invalid example in the Should-help. The example was the one used to illustrate the compound assertion-concept 🙂
Won't implement, I reverted similar functionality in the linked issue. I think soft-assertions are better solution to this.
Summary of the feature request
A common flow I have when doing multiple "Should" in a test looks like:
I would like to simply chain these statements together, especially using Powershell 7 Kusto-style pipeline syntax.
How should it work? (optional)
A new parameter
-And
or-Passthru
which simply emits the object back to the pipeline, enabling this style of test declaration:Or alternatively:
The parameter should be implemented as
-And
but have an alias to-PassThru
since that is a common parameter usage familiar to Powershell users.Willing to attempt a PR if labeled up-for-grabs.