Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a TimerInterface so external packages can mock or spy the timer #41

Closed
robiningelbrecht opened this issue Sep 19, 2023 · 1 comment

Comments

@robiningelbrecht
Copy link

robiningelbrecht commented Sep 19, 2023

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
Copy link
Owner

sebastianbergmann commented Sep 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants