I am writing unit tests for Method1()
I want to mock Method2()
that is called from Method1()
of the same interface.
We can mock methods of another interface easily by taking that mocked implementation in the struct. But I'm not sure how to mock a method of the same interface.
type ISample interface {
Method1()
Method2()
}
type Sample struct {
}
func (s Sample) Method1() {
s.Method2()
}
func (s Sample) Method2() {
}