Closed Kangaroux closed 5 years ago
@Kangaroux
I just remembered that recently we changed the generated code in a way that Return works without preceeding Expect.
So
FooMock.ExpectAnything().Return("something")
Is already supported by the:
FooMock.Return("val")
Notation
So if there are no calls to Expect/When/Then there're no expectations to be met.
@hexdigest Ok great. Is that documented somewhere? I can't test it right now but I recall seeing an error like unexpected call to mock
. I don't believe I set a Return()
on that particular mock, though. So I assume it means that there needs to be at least a Return()
on the mock?
@jesseroux yes there need to be at least a Return() call on the mock. I don't think that documentation explicitly says that you can call Return without Expect.
@hexdigest OK. I'll make a PR later to clarify that then
@jesseroux great! Can you please also mention Calls() method that you just added?
@hexdigest Just to clarify about not needing an ExpectAnything
method, because the current docs say that isn't how it works: https://godoc.org/github.com/gojuno/minimock#hdr-Keep_your_tests_clean
If the docs weren't updated when the Return()
change was made I can just remove that section.
@Kangaroux can you please clarify what confuses you in the docs? What I wanted to say in this section is that Expect/Return/When/Then initialize a mock for some method and if you initialized a mock then MockController.Finish() ensures that this particular method has been called during the test.
The fact that you created an instance of the mock, i.e. readCloserMock := NewReadCloserMock(mc)
isn't checked by Finish() but the compiler won't compile the test if there's no usage of readCloserMock
.
@Kangaroux please follow this thread: https://github.com/gojuno/minimock/issues/30
Maybe new Inspect
helper is enough for you?
Based on #35.
It would be great if a mock could be skipped when the mock controller checks to see if expectations were met. This has several use cases:
Some possible naming schemes:
ExpectAnything
implies that the mock will be called at least once.SkipExpectations
is the least vague IMO.CaptureOnly
makes it sound like aReturn()
wouldn't work which probably isn't the desired functionality.