testify
testify copied to clipboard
mock: add OnF method
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