Skip to content

Mocking object with methods named the same as testify's ones #1715

Description

@frux

Hi! I need to mock an interface which has a method called On.

type MyMockedObj struct {}

func (obj *MyMockedObj) On() error {
    arguments := obj.Called()

    return arguments.Error(0)
}


func TestThis() {
    obj := Obj{}

    obj.On("On").Return(nil) // Error: obj.On("On").Return undefined (type error has no field or method Return)
}

How I supposed to do that?

No activity

Activity on this issue will appear here.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions