【发布时间】:2022-01-18 09:07:44
【问题描述】:
我正在为 Method1() 编写单元测试
我想模拟从同一接口的Method1() 调用的Method2()。
我们可以通过在结构中采用模拟实现来轻松模拟另一个接口的方法。但是我不确定如何模拟相同接口的方法。
type ISample interface {
Method1()
Method2()
}
type Sample struct {
}
func (s Sample) Method1() {
s.Method2()
}
func (s Sample) Method2() {
}
【问题讨论】:
标签: unit-testing go testing mocking testify