testify icon indicating copy to clipboard operation
testify copied to clipboard

mock.Mock is not mock.assertExpectationser: missing method AssertExpectations

Open mohammad-koho opened this issue 3 years ago • 2 comments

Upgrading from v1.7.1 to v1.8.0 results in this for my tests which call AssertExpectationsForObjects:

mock.Mock is not mock.assertExpectationser: missing method AssertExpectations

Called like this:

mock.AssertExpectationsForObjects(t, someRepository.Mock, otherRepository.Mock)

Where someRespository and otherRepository are generated via mockery and defined like such:

type someRepository struct {
   mock.Mock
}

Looking at v1.8.0, I can see the assertExpectationser interface is defined here, and implemented by mock.Mock here.

I see that passing in myMock.Mock is deprecated, and we should pass in myMock instead, but this still results in the same error, just kicks the can up the stack. Eitherway, while deprecated, it'll still work due to this line.

mohammad-koho avatar Jul 14 '22 00:07 mohammad-koho

For me passing in myMock rather than myMock.Mock does fix this, maybe you missed one?

However, you have found a valid bug, this change caused this regression in its attempt to fix a go vet finding. The only way to fix this vet would be a breaking change in the API of AssertExpectationsForObjects.

brackendawson avatar Jul 22 '22 15:07 brackendawson

I would like to see a reproducible test case running on https://go.dev/play .

dolmen avatar Mar 07 '24 14:03 dolmen