|
|
|
|
|
by alien_at_work
3076 days ago
|
|
Completely disagree here. If you test this way you'll be sure to have a correct implementation for this dummy program. Further, if the test fails you now have to try and figure out what component caused the failure. A unit test should test a specific unit; commonly a class. You should have unit tests for the interface of that unit (never private or even protected methods). This absolutely does not prevent internal restructuring but it drive you toward seeing your classes as individual service providers with an interface. |
|
That's the point. If the dummy program fails then your implementation is bad.
> Further, if the test fails you now have to try and figure out what component caused the failure.
Have you heard of logging?
> A unit test should test a specific unit; commonly a class. You should have unit tests for the interface of that unit (never private or even protected methods).
This is almost exactly what I suggested. I stated 'dummy programs' for individual tests because it's more modular and closer to actual usage than mocking. If your language has an equivalent, use that.