News for hackers. Stuff that matters.
Re:Testing Without Mocks by kaczordon on Tuesday February 21, 2023 @11:36AM (#34883131)
No that’s not a mock that’s a stub. See this book from software engineers at Google, it talks about various test doubles: https://abseil.io/resources/swe-book/html/ch13.html
Re:Testing Without Mocks by jmholla on Tuesday February 21, 2023 @11:44AM (#34883279)
They use the word mock several times to explain stubbing. I think they mean stubbing is a type of mocking not an independent approach. They even use a mocking library to create stubs in the Google article.
Re:Testing Without Mocks by Izkata on Tuesday February 21, 2023 @12:13PM (#34883672)
"Mock" can be both a noun and a verb. As a noun, it's an alternative to stubs, fakes, and other such things. As a verb, it refers to the "monkey patching" method of putting those into place, in a way that undoing it is automatic and won't leak into other tests. The title seems to be referring to this second version, showing us ways to avoid patching with things like dependency injection.
Re:Testing Without Mocks by BiteCode_dev on Tuesday February 21, 2023 @12:02PM (#34883507)
Indeed, like people stating something is a deferred or a future instead of promise, and then pointing out a minor difference in their approach that justifies a whole new taxonomy.
Re:Testing Without Mocks by inadequatespace on Tuesday February 21, 2023 @11:46AM (#34883310)
Re:Testing Without Mocks by Aeolun on Tuesday February 21, 2023 @12:11PM (#34883642)
Mocks are for objects, stubs are for responses and ‘fakes’ are basically the same thing as mocks.
Re:Testing Without Mocks by Cyph0n on Tuesday February 21, 2023 @12:14PM (#34883690)
Fakes are not mocks. A fake is an actual (simplified) implementation of the dependency.

For example, if your dependency is a distributed key-value store, a fake would expose the same API but using an in-memory hashmap under the hood.

Re:Testing Without Mocks by Aeolun on Wednesday February 22, 2023 @06:50PM (#34904854)
Yeah no, that’s a mock. At least, that’s been a mock ever since I started prgramming 15 years ago. Only later did libraries that automatically mock dependencies appear (and I presume people suddenly felt a need for a new name for not-automatically mocked dependencies?