3 ms·
> Make a dependency interface "SendEmail(userID int, content []byte) (SendGridResp, error)". Inject that. Am I an idiot for thinking of this as a Mock? This is
by Maxion 3y ago
> Make a dependency interface "SendEmail(userID int, content []byte) (SendGridResp, error)". Inject that.
Am I an idiot for thinking of this as a Mock? This is how I mock things anyway
- sethammons 3y agoIt is maybe a semantics issue. See https://martinfowler.com/articles/mocksArentStubs.html https://martinfowler.com/articles/mocksArentStubs.html. Traditionally, a mock asserts against internal behavior while a fake does not.
- Maxion 3y agoI think it probably is, it seems like certain parts of the tech community has a more specific language for talking about things, and other parts have a less specific.
- seadan83 3y agoMock vs a fake. The difference lies in where the behavior is specified. In a fake, the behavior is hardcoded or simple. With a mock, it is each test that says what the behavior is. The two scale differently. Mocks are per test, fakes are once.