Skip to content

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

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