Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

STUBS method #24

Closed
duskhacker opened this issue Jan 27, 2016 · 9 comments
Closed

STUBS method #24

duskhacker opened this issue Jan 27, 2016 · 9 comments

Comments

@duskhacker
Copy link

Ok, now that we've got the *Times thing out of the way, the other thing I really miss is a STUBS method. I'd like to discuss this first with you before I go and try to contribute it, maybe cut down on the back-and-forth a bit.

When I've used other mocking frameworks, I use

  • A "STUBS" method to indicate "This test does not care that this method is called, it is simply here to allow the code under test to run"
  • A "EXPECTS" method to indicate "This is the expectation that this test cares about"

Would you be open to that addition?

@dsymonds
Copy link
Contributor

STUBS is just EXPECT + AnyTimes, is it not?

@duskhacker
Copy link
Author

It's more like EXPECTS.Call(gomock.Any()).Anytimes()

@duskhacker
Copy link
Author

In fact, the above is pretty much what I'm using now, but IMHO, STUBS would make tests clearer.

@dsymonds
Copy link
Contributor

Yeah, that's what I meant. So it'd be just syntactic sugar for that?

@duskhacker
Copy link
Author

Yes, no arg checking, no checking of number of calls.

@duskhacker
Copy link
Author

And to be clear, yes, it's syntactic sugar.

@dsymonds
Copy link
Contributor

My initial instinct is to say no. I don't want to complicate the API for something that is relatively simple to do already. People have been using gomock to produce stubs for years without issue.

But I'll have a think about it.

@duskhacker
Copy link
Author

Ok, I respect that. I just want to add that I think it would make scanning through tests easier and clearer if STUBS was available, and people coming from other mocking frameworks might miss it like I do. I'll of course defer to your decision when you've thought through it.

@dsymonds
Copy link
Contributor

dsymonds commented Feb 2, 2016

I think I'd prefer to leave things as they are. Thanks anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants