Skip to content

Failed to mock the methods of self defined class #40

Description

@ilovewchao

@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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions