3 ms·
Eventually you learn not to need mocks. It's a long road though. An important first step is making your dependencies very very simple functions that are trivial
by caoilte 10y ago
Eventually you learn not to need mocks. It's a long road though. An important first step is making your dependencies very very simple functions that are trivial to define on the fly.
- misja111 10y agoYes I agree, in Scala mocks are not as useful as in Java and the Scala language has some features that make it easier to work around them. However what I don't understand is what is so great about MacWire. Maybe I'm missing something but I always believed that the main advantage of a DI framework was that it facilitated mocking. If this is not needed in Scala, then what is so great about MacWire?
- caoilte 10y agoYou're right. The biggest thing that DI frameworks have historically done for me is make mock injection easier. There are other benefits, however. - Manual wiring generally has quite a lot of boiler plate (even in Scala, especially if you use free monads) - DI frameworks enforce a pattern of behaviour. This can be especially helpful when navigating a project. Having said that, whether these benefits are worth the cost of a DI framework is debatable. My current weapon of choice is FreeK...