-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Consider using Assert-Error instead of Assert-Throw #16
Comments
Well simply put, powershell commands take the form of verb-noun, not verb-verb :) I vote for Assert-Error and have parametersets for string (e.g. error message), FullyQualifiedErrorId and exceptions. FullyQualifiedErrorId is good because it is language (as in locale) agnostic. |
In fact, this can be simplified as the error message (e.g. |
+1 for |
I personally use |
Gotcha, I like it as well, but I also want to be consistent with the other assertion names. Thinking about it the assertions would be much better fit for custom operators than functions. In the end that's what they mostly are - operator adapter that throws for $message ?eq 'olleh' ( It would also suck when the actual side (left-hand-side) would determine the type to use for the comparison, instead of the expected (right-hand-side). As we already witnessed in one of the early versions of Pester 4. :)) ) I'd like to move to proper nouns to follow the PowerShell naming conventions as much as possible, and I can imagine calling |
IMHO |
Revisiting this after some time and I am still not sure about the name.
At the moment I am inclined to use But what about non-terminating errors? Does anyone need to capture those and assert on them? Connected to that there would probably be call for asserting the other types of output, and so the assertions could becalled Maybe aliasing it would be permissible, would script analyzer then complain that you should use Assert-Error? That would be great, because the user would get many to choose from, and be steered to use the one true choice (and possibly confusing as hell, so let's wait wait this.) In the future we might need assertions that will look at the actual errors and exceptions and those I would probably call |
Now that it was mentioned on twitter, I like the idea of calling the assertion for errors/exceptions
Assert-Error
instead ofAssert-Throw
. It seems more discoverable.On the other hand,
Assert-Throw
seems to suggest that the input code will throw something after we execute it. WhileAssert-Error
sound like we already got an error object and now we are inspecting it.So simply by the names I would expect that
Assert-Throw
consumes scriptblocks:while
Assert-Error
consumes errors, without actually executing any code:But maybe the developer in me is reading too much into the names.
Opinions?
The text was updated successfully, but these errors were encountered: