Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
hacker_9
on Oct 27, 2017
|
parent
|
context
|
favorite
| on:
Write tests. Not too many. Mostly integration
How many static classes are your methods using? And what is the problem with injecting this stuff at the top of the class instead? If you plan to write tests, you have to control your dependencies, and DI is the simpliest way to do that.
quickthrower2
on Oct 27, 2017
[–]
Because these tests become too detached from reality if you inject everything. A silly example to make the point:
IAdder { double Add(double a, double b) }
Test:
car mockAdder = ... // Mock 1+1=2 etc.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: