TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

I don’t believe I have to say that Unit tests are good for you

2 pointsby victorroninover 2 years ago

2 comments

osigurdsonover 2 years ago
&gt;&gt; Why unit tests are good?<p><pre><code> Regression testing </code></pre> In my experience in a heavily tested code base (unit and integration), this is more of the role of integration tests. However unit tests are ultra valuable for code that has few dependencies. The higher you go in the stack the muddier it seems to get.
throw310822over 2 years ago
&gt; if he spent barely 20 minutes writing 3–4 trivial unit tests for this function, we would have saved probably 6 hours each ... The math was beyond simple. 20 mins invested and 12 hours saved.<p>I&#x27;ve heard this reasoning before. The math is simple but wrong. The cost of writing unit tests must also include the time spent on tests of stuff that was never broken; and for the maintenance of tests that break because of new features or bug fixes rather than actual code issues.<p>Unit tests are very useful, essential, in some situations. In others they&#x27;re a waste of everybody&#x27;s time.