I'm using golang's gomock package to write some tests and in order to make my tests more general and focused on the end goal I want to write them without having to explicitly state each interface call that should happen.
For example, currently I have something like this for a function that calls Bar()
mockFoo := NewMockFooInterface(mockctrl)
mockFoo.EXPECT().Bar()
bar := functionToTestThatUsesFooInterface()
if bar != expectedResult {
t.Errorf("error")
}
Is it possible to write the same test, but without the EXPECT call()? If I take that line out, I'll have an error like Unexpected call to MockFooInterface.Bar()
.
Aucun commentaire:
Enregistrer un commentaire