Add a TimerInterface so external packages can mock or spy the timer
robiningelbrecht opened this issue · 1 comments
robiningelbrecht commented
Currently the Timer
class is final
, which means it cannot be mocked or extended and that's ok for general usage.
But because of this external packages cannot properly test any classes using the this timer.
Introducing an interface for the timer would fix this problem... or am I missing something?
sebastianbergmann commented
This is outside the scope of this project (as I do not have any use case where I need to isolate Timer
from code that uses it for testing).
However, you should not double what you do not own. This means that you should not use Timer
directly in your code. Instead, you should define an interface that you own and implement a class that implements your interface using Timer
.