Testing · Senior · Question 60 of 75
Why is dependency injection helpful for testability?
- ✓Correct answer: Dependencies (clock, HTTP client, storage) can be replaced with doubles without module-mocking tricks
- 2It makes code run faster
- 3It removes the need for tests
Explanation
Passing a now() function or an API client as a parameter is the simplest form of DI.