Skip to content
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

match function call prefer later mock.On #1390

Closed
wants to merge 1 commit into from

Conversation

egolearner
Copy link

Summary

Match function call prefer later mock.On.

Changes

Iterate backwardly in findExpectedCall/findClosestCall

Motivation

If there are multiple mock.On statement, it's natural to prefer later mock.On to earlier mock.On.

Related issues

Closes #1375

@egolearner
Copy link
Author

From my point of view, it's natural to write the in the following way

mock.On(...)
doSthWithInterface().Expect(mock arg or mock return)

mock.On(...)
anotherDoSthWithInterface().Expect(mock arg or mock return)

instead of

mock.On(...)
mock.On(...)

doSthWithInterface().Expect(mock arg or mock return)
anotherDoSthWithInterface().Expect(mock arg or mock return)

However, this modification breaks a lot of tests. I need to know if this is the right direction to go.

@dolmen
Copy link
Collaborator

dolmen commented Oct 16, 2023

This is a breaking change. No way to have it accepted while maintaining compatibility.

@dolmen dolmen closed this Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How can I retire mock.On condition to allow mock to match later mock.On?
2 participants