-
-
Notifications
You must be signed in to change notification settings - Fork 478
Print mock history #2673
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
base: main
Are you sure you want to change the base?
Print mock history #2673
Conversation
|
Would Another nice to have would be identifying where the call came from (e.g. line number, file, etc.). This could be helpful in identifying mocked calls that are similar but for some reason the logic branch didn't hit them. I wonder (in another PR) if we flipped this on its head, and made it so we could evaluate what would be mocked (so read in the test file first) and then parsed a script and returned a list of mocked (with what criteria passed/failed). I know that would help me for sure. The other nice thing with this is that if we failed to properly mock, we would know that before running potentially system impacting commands. |
What else shows success or not success , call or not call, that is not + or -? It should also be easy to grasp and hard misunderstand, and the format should work when there are 0 calls.
I agree. Seeing where the mock call came from would be nice. There is even more info that can be printed, e.g. why it did not match ( we cannot explain exactly why, but can at least show the filter that was used).
I feel like all of this info already is in the debugging log. And it is a lot of info to help you debug mock calls that behave differently than you thought.
In version 6 the mocks will never fall through to the real command so this is less of a concern, but I see it still apply when you for example don't mock correctly in a module scope. It is hard to protect you from that though, as it means we would have to push mock into every single mock scope (or hijack the execution). |
|
I think I need to add the location (describe / it) from where the mock came probably? (Get-AllMockBehaviors is probably the right place where to attach the block / test to the behavior, so we can later get the description from that.) |
Yea that makes sense. Plus +/- being pass fail makes more sense that as a signifier in this situation. How about this? |

Wanted to spend few minutes on this, since I always say that it would be nice to have. LMK what you think before I start polishing it.
I struggle with identifying which mock was or was not invoked, and why, especially when validating that some cmdlet is called with the correct parameters.
It improves the situation a bit, but to make it really useful, maybe: