ShaunCodeweaver
ShaunCodeweaver on Hacker News
Would love to know the best way people handle this.
The Anti If Campaign
If your paranoid about null pointers in C/C++, use asserts or static analysis.
You've got a missing class. The fact you're so concerned with testing it highlights this.
The fact it's private I should be free to rename, add or remove parameters. If I did this to your private method, I'd break unit tests, despite the code being private.
For the null reference problem, it depends on your language. But the point remains the same. For public API's, e.g something you let the outside world consume, checking for null etc.. will be required. For internal code, don't bother. Go as high as you can in the stack and fix the root cause of the null reference in the first place.
Testing private methods? Wrong. Don't do this. They'll be covered by your public API, if they aren't, delete them. If you need to test code that is private, you've got a missing abstraction. Pull that code out into a separate class, make the method public.
Testing you get a null reference when you send in null to a method? So what? You're testing Java/C#/etc... if you do this. Test for behaviour.
Need to use tear down methods? You're not unit testing anymore.
At least the article never recommended testing accessors... Again, please don't.
MVC is broken
Auto updating browsers suck for developers... sort of
Achieving More Isolated Unit Testing
Hammer down and there are some good quotes/ideas in there.
Recursively building a Web Service - using the same Web Service
Why treating build warnings as errors is important
With good unit tests you can indeed refactor without fear, but we should not take the stance of never breaking any unit tests. Providing there is no functional change, break away! Such stance relies on end to end tests/pairing/some other process to ensure you are not breaking valid behaviour though.