Comment by realusername
5 years ago
Maybe that's possible in theory but I've never encountered a statically language where I consider the testing frameworks "good enough".
5 years ago
Maybe that's possible in theory but I've never encountered a statically language where I consider the testing frameworks "good enough".
I'm not sure what to make of that. Maybe you just haven't bothered to look? You personally not knowing about something is a reflection of your own knowledge, and not of the state of the world.
No, I've look enough I think. Maybe those better frameworks do exist though indeed, but I have no proof of that. Usually they just have the bare minimum of assert checks and call it a day.
A testing framework should be able to mock and patch any class (or applicable) of the running instance of the program without modifying your code for example, tell me if a method was executed or not, intercepting all HTTP requests without changes, have complex assertion partially matching objects, factories, change the current time... I could add a lot more here.
All of that is necessary harder I think in a static typing environment.
> mock and patch any class (or applicable) of the running instance of the program without modifying your code
Why is it important for the sake of testing to be able to alter the runtime behaviour externally without changing the code? This is contrary to all TDD literature I've read which advises to make production code easy to test, e.g., by coding against interfaces. After all, something being hard to test is exactly the feedback you're looking for when doing Test Driven Design. If it's hard to test, it's probably too tightly-coupled.
> tell me if a method was executed or not
Spies are possible with e.g. the ReaderT pattern.
> intercepting all HTTP requests without changes
My earlier two points are applicable here too, although I'll add type classes as another viable solution.
> have complex assertion partially matching objects
Pretty easy with lenses or just making assertions against record field lookups.
> factories
I don't know what this means. I looked at several articles describing some kind of factory pattern in TDD — all of which were horrifically verbose — and all I can glean from that is we are talking about mocking some function which generates objects.
> change the current time
This is no different from mocking other system boundaries, which I have already addressed.
> I could add a lot more here
You're welcome to, and I imagine my suggested solutions will continue to follow a theme. I'm not sure you're here to have your mind changed though. It seems you've reached your conclusion already.
1 reply →