throwaway7375
Re:Stepping down as Mockito maintainer after 10 years
on Monday December 29, 2025 @04:39AM (#46418957)
What is the alternative? If you write a complete implementation of an interface for test purposes, can you actually be certain that your version of x.isEmpty() behaves as the actual method? If it has not been used before, can you trust that a green test is valid without manually checking it?
When I use mocking, I try to always use real objects as return values. So if I mock a repository method, like userRepository.search(...) I would return an actual list and not a mocked object. This has worked well for me. If I actually need to test the db query itself, I use a real db
Re:Stepping down as Mockito maintainer after 10 years
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.
Re:Stepping down as Mockito maintainer after 10 years
on Sunday December 28, 2025 @05:58PM (#46415375)
Before Mockito, it was common (where I worked) to create an interface just to support testing. This is an anti-pattern in my opinion. To create interfaces just for testing complicates the code and it is one of my pet peeves. It also encourages the factory pattern.
I prefer Mockito's approach.