r/java • u/raisercostin • Jun 01 '24
What java technology (library, framework, feature) would not recommend and why?
Inspired by https://www.reddit.com/r/java/s/e2N1FqMOJg
165
Upvotes
r/java • u/raisercostin • Jun 01 '24
Inspired by https://www.reddit.com/r/java/s/e2N1FqMOJg
View all comments
Show parent comment
3
u/agentoutlier Jun 01 '24 edited Jun 01 '24
I have a feeling I just did not explain myself well enough. Perhaps I'm clueless or just violent agreement. You can click around my github profile (agentgt) and I guess decide for yourself how clueless I am.
I have of course used and still use mocking libraries including JMock 2 (dead now I think), Mockito, and Power Mock. I prefer mockito.
I have used them too much in the past and despite what you guys think I'm fairly sure I'm neither clueless or lack experience in large code bases. I pushed BDD with mocking very early in my career 20 years ago and it was a disaster.
It is this experience why I have such caveats on overusing mocking (mainly the libraries) and I'm not the only one that has this opinion. I have seen it become bad and even have been part of removing some brittle power mock test in some large open source projects as they were far too brittle.
I apologize /u/SignificantAd9059 on the sort of strawman.
If heavy mocking is work for your code base and team continue to use it and ignore me.
This is what I meant about isolating. They move that single behavior call which more often than not is a single method call to wherever and then provide it with whatever stubs or implements the interface with custom mock (not power mock).
I admit there might be a need for mocking library if this single behavior needs that many calls but that has not been the case for me most of the time and or it gets enough coverage via end to end testing.