Closed ryanking8215 closed 2 years ago
Sorry, it is not a bug that I found the issue is the misusage of Ginkgo.
GinkgoT() is return a testing proxy instance which implement an dummy Cleanup
function, it is not the *testing.T instance passed to RunSpecs
.
Solution:
gomock.NewController
or
Actual behavior A clear and concise description of what the bug is. Times() checking is not correct, i.e, the mock function is called exact 1 time. But the testing will pass if
mockObj.EXPECT().Func().Times(2)
, any number >=1 will all satisfy the checking.Expected behavior A clear and concise description of what you expected to happen. Testing should be failed if pass the number which is not the exact number of function call by using Times()
To Reproduce Steps to reproduce the behavior
interface and caller definition
testing code
Additional Information
Triage Notes for the Maintainers I am not sure it is a bug or it is designed on purpose. But the behave of Times() checking is counterintuitive.
I read the source code, the method
Caller.satisfied()
is not invoked by caller instance itself, it is invoked by caller's preReq list.