withmock icon indicating copy to clipboard operation
withmock copied to clipboard

Failed to mock the methods of self defined class

Open ilovewchao opened this issue 10 years ago • 0 comments

@qur I don't no how to describe the problem clearly, so I have wrote some cases to show it. You can see them here: https://github.com/ilovewchao/withmock-test.git

In brief words, when I define a 'type struct Baz{}' without any filed, 'withmock go test' will PASS; but when Baz is defined as 'type struct Baz{name string}' which contains a filed, the test will fail:

--- FAIL: TestTryMe (0.00 seconds) controller.go:113: no matching expected call: *baz.Baz.DoSomething([]) controller.go:158: missing call(s) to *baz.Baz.DoSomething() controller.go:158: missing call(s) to *fmt._packageMock.Println(is anything) controller.go:165: aborting test due to missing call(s) FAIL exit status 1 FAIL github.com/ilovewchao/withmock-test/foo 0.003s

Hope you can help me with the issue. Thank you!

ilovewchao avatar Jul 15 '14 12:07 ilovewchao