Re:Generating a Java program with 90% less code
by chinhodado on Wednesday December 04, 2019 @02:03PM
(#21705731)
It's the same with Java where it's very hard/not possible to mock final methods. It's just that methods in Java are virtual by default so it's less "in the way" when you need to mock something.
Re:Generating a Java program with 90% less code
by apta on Wednesday December 04, 2019 @05:38PM
(#21707995)
What do you use instead of mocks when testing?
Re:Generating a Java program with 90% less code
by GordonS on Wednesday December 04, 2019 @06:10PM
(#21708186)
Real instances of the dependant class.
A "unit test purist" would likely shun this, but I take more of a realist approach; in many real-world cases, mock-heavy tests make for brittle tests that don't give confidence of correctness.
I tend to focus on integration tests, as I find these provide the most value while still executing very quickly (depending on the stack, obv).
That doesn't mean I don't use unit tests, or that I never use mocks - I just use mocks very sparingly.
It's one of the reasons I tend to minimise my use of mocks as much as possible.