Go Test/Mock
goMock
在使用goMock的Times(MinTimes, MaxTimes)這個功能時,要記得在你宣告的NewController完後,在你執行完所有的mock的function之後,執行ctrl.Finish()的動作
func TestFoo(t *testing.T) {
ctrl := gomock.NewController(t)
// Assert that Bar() is invoked.
m := NewMockFoo(ctrl)
// Asserts that the first and only call to Bar() is passed 99.
// Anything else will fail.
m.
EXPECT().
Bar(gomock.Eq(99)).
Return(101)
SUT(m)
ctrl.Finish()
}