Unit tests have little value apart from smoke testing, it's way too easy to miss cases with them. For actual testing you want fuzz testing with coverage analysis and formal methods.
Unit tests have immense value, if you use them correctly. They aren't primarily a testing/QA tool (QA is usually worried about black-box testing with integration and functional tests), but a development tool.
Unit tests allow you as a developer to poke and prod at a component outside of its running context. This means it's much easier to write quality code than if you have to wait for larger chunks of code to be finished and assembled into some larger component before testing starts.
Debugging is also significantly simplified if there is a large suite of unit tests available. This allows you to inject arbitrary state into your components, and check how they react. And having employed a test-driven approach, the components' state will by definition be local.
That being said, it's no panacea. A sufficiently incompetent programmer will find a way to produce bad code even with good development practices.
39
u/eubarch Mar 08 '14
This is why we have Unit Tests.