4 ms·
> Mox is nothing more than a kludge to get around the limitations of the language and I think there are much less invasive kludges available. To be honest when
by thibaut_barrere 3y ago
> Mox is nothing more than a kludge to get around the limitations of the language and I think there are much less invasive kludges available. To be honest when I’m working with devs who are new to elixir I’m embarrassed when I have to explain how Mox works.
There are other ways, more similar to Ruby etc (e.g. https://github.com/edgurgel/mimic https://github.com/edgurgel/mimic, or with_mock etc).
And also there is the risk to "over-mock", for sure.
But a good middle ground brings the right value here!
- sarchertech 3y agoI’ve used mimic an I think it’s a much better option than Mox.
- sph 3y agoWe spoke about this topic for far too long today, but looking at Mimic and its "nothing is mocked unless I tell you to" design, it works only iff you are using mocks the wrong way and at the wrong boundaries.
- sarchertech 3y agoThere’s no reason you can’t setup your tests so that mimic stubs out your module or a subset of functions in your module everywhere where you don’t explicitly override it. The main difference is that the extra dispatch layer is only injected at test time, so there’s no extra indirection in the production code.