|
|
|
|
|
by lmm
2986 days ago
|
|
> Languages have strengths and weaknesses. Certain tasks are easy in some languages, and certain other tasks are not. Agreed, but we mustn't fall into the fallacy of assuming that means no language can ever be better or worse than another. There are good and bad language design choices, and "an implementation of interface foo that returns bar when called with baz" is not some obscure specialized feature, it's the basics of general-purpose programming. > Throwing ones hands up and saying "something is very wrong with your language" because one is not familiar with a technique or tooling popular in another language is immature, IMO. I'm very familiar with the techniques and tooling of mocking frameworks. I do not make these claims lightly. |
|
Agreed.
> "an implementation of interface foo that returns bar when called with baz" is not some obscure specialized feature
It isn't some obscure specialized feature in Java either.
What mocking frameworks do is to provide a DSL to describe behavior of such implementations, use dynamic bytecode generation (not reflection, BTW) to create implementations of the interfaces dynamically, and bind them to simulate various test conditions. What the makes the language "worse" to require or allow doing this?My Haskell is rusty, but given Haskell psuedocode like:
how would you test that the two branches of main behave appropriately?This is not a snark; I am truly interested to know how Haskell gets rid of the need to bind alternate implementations of an interface for testing purposes.