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

Support mocking non-accessible parent methods #785

Merged
merged 1 commit into from Feb 7, 2022

Conversation

npars
Copy link
Contributor

@npars npars commented Feb 2, 2022

  • Add support for mocking non-accessible parent methods using Mockk
  • The class being mocked is always searched first for the specified
    method, then all superclasses are checked in no specific order. If
    multiple superclasses have matching signatures for the method then
    there is no guarantee which will be chosen.
  • Fixes can't find private function inside superclass for dynamic call #425

- Add support for mocking non-accessible parent methods using Mockk
- The class being mocked is always searched first for the specified
  method, then all superclasses are checked in no specific order. If
  multiple superclasses have matching signatures for the method then
  there is no guarantee which will be mocked first.
- Fixes mockk#425
@npars
Copy link
Contributor Author

npars commented Feb 2, 2022

Regarding the issue where multiple superclasses have the same method signature. I think that could be solved in the future by allowing the user to "hint" what class contains the method they wish to mock somehow. That would guarantee that the correct method ends up getting mocked.

@Raibaz
Copy link
Collaborator

Raibaz commented Feb 3, 2022

This looks pretty cool, thanks a lot for sending this through!

I'm a bit concerned about performances, but the fact that sequenceOf(this) is at the beginning of the sequence of methods being looked up makes me think existing code is not going to be affected by this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't find private function inside superclass for dynamic call
2 participants