Closed Zurvarian closed 9 months ago
Hello and thank you for the feedback.
Regarding this issue, there's been a misinterpretation of how verifyNoMoreInteractions
should work from my side, so I will fix it soon.
However I also see that your example should indeed succeed.
From what I see in mockito, this test should fail:
@Test
void verificationTest() {
ExampleInterface exampleInterface = mock(ExampleInterface.class);
exampleInterface.Foo1(1);
exampleInterface.Foo2(12);
verify(exampleInterface, atLeastOnce()).Foo1(1);
verifyNoMoreInteractions(exampleInterface);
}
And this test should pass:
@Test
void verificationTest() {
ExampleInterface exampleInterface = mock(ExampleInterface.class);
exampleInterface.Foo1(1);
verify(exampleInterface, atLeastOnce()).Foo1(1);
verifyNoMoreInteractions(exampleInterface);
}
So I will fix the current bug by replicating mockito behaviour.
Thanks!, really love to see this lib in Golang.
Hope it gets enough attention from the Go Devs 😉
Done, the behavior of this check is now aligned with mockito. Could you please check and confirm? Fix version is v0.4.8 Keep in mind that error description is now not very verbose and will be fixed here
Checked, and now it is working as expected.
However I've found another, much more subtle issue. I'm opening another ticket to not mix things up.
First, kudos for this great library, I come from Java world and, honestly, it has been quite a bummer how bad is mocking in Go...
Now, I've been evaluating your library to introduce it in our stack, and while doing so I've found that the behaviour of VerifyNoMoreInteractions is not doing what the GoDoc says it does.
The GoDoc says:
But when I've tried exactly that, the test is not failing as expected. Moreover, I've downloaded this project and tweaked the test that is verifying the VerifyNoMoreInteractions method to follow this exact GoDoc (i.e. I've added a verify(m, Once()) and I could see the same behaviour.
When I run this, I get:
../mockio/tests/verify/common.go:40: Expected error, got nothing