Code Monkey home page Code Monkey logo

Comments (4)

tscales avatar tscales commented on June 11, 2024

I tried reproducing based on your code was unable to. The following test passes for me.

type Email interface{}

type Mailer interface {
	Send(email Email, receiver string)
}

type MockMailer struct {
	mock.Mock
}

func (m *MockMailer) Send(email Email, receiver string) error {
	args := m.Called(email, receiver)
	return args.Error(0)
}

func TestMailer(t *testing.T) {
	mailer := new(MockMailer)
	mailer.On("Send", mock.Anything, mock.Anything).Return(nil)

	err := mailer.Send("hello", "world")
	assert.NoError(t, err)
}

from testify.

brackendawson avatar brackendawson commented on June 11, 2024

You've most likely either missed this line from your test:

mailer.On("Send", mock.Anything, mock.Anything).Return(nil)

or misspelled "Send", or your test was using a different mailer mock instance than you expected.

Can you make a minimal compilable example that fails?

from testify.

st3penta avatar st3penta commented on June 11, 2024

I confirm what @tscales said, i can't reproduce the issue either. Here is a working snippet

from testify.

brackendawson avatar brackendawson commented on June 11, 2024

Please comment again, or start a discussion (tab up top), if you still have this problem.

from testify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.