Is it possible to mock a function imported from a package?
Yes, with a simple refactoring. Create a zSomeFunc variable of function type, initialized with z.SomeFunc, and have your package call that instead of z.SomeFunc(): var zSomeFunc = z.SomeFunc func abc() { // … v := zSomeFunc() // … } In tests you may assign another function to zSomeFunc, one that is defined in tests, and … Read more