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.

[Ask HN] Teach me how to unit test

1 pointsby uptownhrabout 11 years ago
Unit testing... Everyone knows what it is. However, when ever I try, I feel like I ended up wasting a lot of time and feel that my tests do nothing. Even worst, I feel like I cannot write tests for many things that I feel are important.<p>How can one learn to do proper unit testing? I see bunch of examples but none that really help me. I almost feel like a unit testing needs to be taught and hard to learn on your own.

1 comment

vivekchand19about 11 years ago
Unit testing is all about abstracting &#x2F; mocking out all the modules connected to the unit you are testing &amp; just test your unit.<p>If you are programming in python, <a href="http://www.voidspace.org.uk/python/mock/" rel="nofollow">http:&#x2F;&#x2F;www.voidspace.org.uk&#x2F;python&#x2F;mock&#x2F;</a> would be the most preferred way of mocking out other external units connected to your unit under test.<p><a href="http://alexmarandon.com/articles/python_mock_gotchas/" rel="nofollow">http:&#x2F;&#x2F;alexmarandon.com&#x2F;articles&#x2F;python_mock_gotchas&#x2F;</a> should make you an expert on mocking