-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
Way forward for Should? #1423
Comments
Should Be that community use Assert module rather than Should? Seems much friendlier, some Rules to Better Pester Tests would be good. Could this be done by aliasing the commands? By a configuration or feature toggle to enable in Pester v5? Some of the features are great in Assert (eg. compare), some are a bit odd naming and could be leveraging some built-in commands (eg. Format-Nicely?) but are useful too! Is it possible for the assert module to be added to a Microsoft Trusted Repository rather than PSGallery? Or perhaps a wiki page could be added for Azure Devops integration of Pester + Assert. |
@asears Thanks for the suggestions. Assert was my playground to find what is possible, and to look at assertions from a different angle. In some cases I went too far, and then returned back (e.g. -Be which was different per type, which get's pretty annoying especially for numeric types). I think that the biggest problem is getting it to people, because I presented about it multiple times, and I always get asked if it will become part of Pester, as if installing it from the gallery would be difficult. I would also like to see it in Pester, because the current assertions are a bit difficult sometimes. I think that aliasing is a good option, and it was suggested on slack, I am just not sure what to do with the actual commands that will be exported. Sooner or later someone will use them somewhere and then they will need to be supported. They will also pop-up at the top of the list in It would be nice to keep it consistent as well. In Pester v5 I am already working with
What is that, and what would it bring? |
Thanks for answering my questions. It sounds like Assert should be merged into Pester, with some refactoring done on the Assert repo prior to this / during this. Maybe an interim fork with two options for running Pester with optional Assert? Changing apis while remaining backwards compatible is hard. When I install Assert it's showing up as "untrusted" as all modules coming from PSGallery seem to be by default. Setting up a trusted artifacts library in Azure Devops is one way around this. Publishing / promoting more info on Assert within Pester readme.md and wiki might help. Will see if I can bring the discussion to Slack. |
@asears I am open to suggestions on the refactorings, if you want to share 🙂 |
About the module warnings on non-canonical verbs, try this:
|
@fsackur thanks, I will try it :) |
I think the plan could be this:
|
|
@fflaten FYI I am working on porting Assert assertions to Pester. To ship them side-by-side with the current |
Thanks for the update 🙂
Is this part of the plan scrapped? Future custom operators should be standalone functions only to keep things simple? |
Currently I am more inclined to doing 1 migration to the (hopefully) better solution which is Assert assertions. My plan here is to:
yes |
Should assertions have multiple quirks and pain points, here is a not-complete list:
-Be
does too much, so it is hard to understand what is happening-Be
has special logic to revert this, which does not always workShould -BeFalse -AllowNull -AllowTypeCast -FalseStringAsFalse
,Should -BeString -CaseSensitive
,Should -BeCollection -All { $_ -like "*file.ps1" }
) because parameter sets limited to 32 parameter sets per functionI researched the various limitations of Should by writing a separate module Assert which has nice functionality but is not used often because people are not aware of it. I think it would be wort it to merge the functionality into Pester and fix some of the quirks finally. But I am wondering what ways forward I actually have.
There are few more limitations:
The text was updated successfully, but these errors were encountered: