Skip to content

mock: add OnF method#1814

Open
burik666 wants to merge 2 commits intostretchr:masterfrom
burik666:OnF
Open

mock: add OnF method#1814
burik666 wants to merge 2 commits intostretchr:masterfrom
burik666:OnF

Conversation

@burik666
Copy link

Summary

Adds OnF method to mock.Mock and mock.Call to allow defining mock expectations using function references instead of string method names.

Changes

  • Added OnF method to mock.Mock and mock.Call.
  • OnF extracts the function name using reflection and runtime information.
  • Provides a more type-safe, refactor-friendly alternative to On.

Motivation

Currently, mock expectations are defined using string literals for method names, which can be error-prone and break easily during refactoring.
OnF allows developers to use actual function references, improving type safety and maintainability.

Related issues

#425

@burik666
Copy link
Author

bump.
what do you think about this?

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.

1 participant