Re:Stepping down as Mockito maintainer after 10 years
by deepsun on Sunday December 28, 2025 @04:51PM
(#46414877)
Google API libraries mark every class as "final" so it's not trivial to mock-extend it for tests. But third-party IO is exactly the thing you'd want to mock.
Probably because they zealously followed "Effective Java" book.
Re:Stepping down as Mockito maintainer after 10 years
by wiseowise on Sunday December 28, 2025 @05:33PM
(#46415212)
> But third-party IO is exactly the thing you'd want to mock.
You write an adapter.
Re:Stepping down as Mockito maintainer after 10 years
by deepsun on Sunday December 28, 2025 @05:57PM
(#46415373)
No, some other library classes accept only their own, not my adapter.
Not mentioning of course needless copy-pasting dosens of members in the adapter. And it must be in prod code, not tests, even though it's documentation would say "Adapter for X, exists only for tests, to be able to mock X".
Re:Stepping down as Mockito maintainer after 10 years
by wiseowise on Sunday December 28, 2025 @06:01PM
(#46415398)
You wrap whole 3rd party dependency in an adapter.
Re:Stepping down as Mockito maintainer after 10 years
by akoboldfrying on Sunday December 28, 2025 @10:25PM
(#46417164)
That's a lot of upfront work and maintenance, not to mention the friction of needing to mentally translate every occurrence of OurFooAdapter to Foo in order to find documentation.
Re:Stepping down as Mockito maintainer after 10 years
by wiseowise on Monday December 29, 2025 @03:27AM
(#46418587)
Yeah, well, good code takes some thought to produce. More news at 11.
Re:Stepping down as Mockito maintainer after 10 years
by deepsun on Monday December 29, 2025 @05:28PM
(#46426592)
The second argument still holds -- all those wrappers will exist in prod only for tests.
Moreover, that wrapper library is now a pretty large piece of code, and we'd want to maintain and test as well. But cannot without hacks.
Re:Stepping down as Mockito maintainer after 10 years
by throwaway7375 on Sunday December 28, 2025 @06:11PM
(#46415461)
Once you start writing adapters you need a way to instantiate them to choose between implementations, and factories is often used for this. Then you might generalize the test suites to make the setup easier and you end up with the infamous FactoryFactory pattern.
On the one hand, you should just design things to be testable from the start. On the other... I'm already working in this codebase with 20 years of legacy untestable design...