How do you guys feel about this subject? I personally think we should only test public methods since those would test private methods as well. Yes: test everything No: only test public methods
test everything. also your poll is ambiguous. not sure if yes means we agree with you or if we should test private methods
we just make important private methods internal and write unit tests
That's what friends are for!! lolol!!
Test whatever makes sense in order to get confidence in your deliverable and ensure ongoing quality. You're paid to make your customer happy, not for writing unit tests.
Test every effing piece of the code. Test exceptions. Have your test coverage over 95% (though my best project till now has only 80%)
only test the public methods, the interface to your class. Else your tests will become really brittle and will stop you from being able to refactor your code in the future. To get decent code coverage this way you may need to split your class into multiple smaller classes or use dependency injection to abstract away components like the file system or a database.
There is no way half the people on here do something that is totally against any kind of best practices...
Assuming people put as much care into their code as their messages here, I can easily believe it.
You should never bother testing private methods. If you consider something private to be tested, just factor it out into a separate class and test its (now public) methods as much as you want.
...and now you have two problems... :p
Don't test internal implementation with mocks. At a previous company I worked on a project where the test suite was pretty much a series of "expect this call then this other call" and if you added something in between in the code, you had to go encode that change in the test as well to get it to pass. It was like you had to write the code once in whatever language and then the exact same diff again but in a shitty test/mock DSL.
Yeah. Like the young TDD guys who test getters and setters and even have tests to check if a method exists first.
Depends is the answer, err in favor of yes test them.