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

Unit testing is quite overrated. Testing stuff "by hand" is more or less writing a unit test you delete afterwards.


Sounds like it would be hard to scale yourself, time wise, If you kept deleting the automation.


Unit tests can have the opposite problem; if they never fail they’re not contributing and you still have to maintain them.

They are not the most productive way to get end to end automated test coverage.


They’re still documenting how the code is supposed to behave. If they really never fail no matter how you change the code, you may not be testing the right things.


The issue is that too often they fail not because the code was incorrect, but because it changed and the test/mocks are incorrect. Higher level tests stay valid because they’re things like “none of the command line args should crash”.

Besides that, sometimes code just doesn’t change (say a basic math library). Then you’re mostly testing your compiler, which is useful but an intentional approach would be better.


I agree with your first point. But there’s somebody out there telling us that a true unit test has no mocks. Or something.

Unit tests do come in handy when building a maths library.l or similar. Not in terms of catching a regression, but to help build it in the first place. One of the few places where TDD might actually be helpful.


Not everything is amenable to unit tests, but if you can design a module to be unit testable, you should. And unit tests give others more confidence in your code — they allow other people to modify your code with confidence as well.




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

Search: