4 ms·
[Ask HN] Teach me how to unit test
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.
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.
- vivekchand19 12y agoUnit testing is all about abstracting / mocking out all the modules connected to the unit you are testing & just test your unit. If you are programming in python, http://www.voidspace.org.uk/python/mock/ http://www.voidspace.org.uk/python/mock/ would be the most preferred way of mocking out other external units connected to your unit under test. http://alexmarandon.com/articles/python_mock_gotchas/ http://alexmarandon.com/articles/python_mock_gotchas/ should make you an expert on mocking