Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> besides its use of dependencies

Isn't that sort of the point of the unit test in that case? You test the use of those dependencies:

Write a test where a mocked dependency returns something unexpected and see how your 'unit' responds.

This is why mocks are useful because often you rely on implementation details of your dependencies and only test the happy cases. With a mock you can return whatever edge cases you come up with and ensure your unit handles everything as expected.



No? The point of a unit test is to tell me something non-obvious about how the function behaves in certain circumstances. When unit testing glue code there is no information in the test result that is not also literally written out in the unit under test (it makes these calls in this order).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: