Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’m wondering if the software world has something to learn from digital design here (for once), where there’s a huge emphasis on code coverage collection.

You really shouldn’t care how a function is tested. That there exists a test for that particular function isn’t particularly useful measure of how well the function is tested. So you need a methodology that tells you which of your functions have been covered by your tests. If it’s not covered you should make a judgement about how to get that coverage.

Getting your private methods covered by the public interface is good because it encourages you to write thorough tests for those public methods that covers all the ways the method might be used.



I agree a lot with this, and want to add that if you have a lot of complex private logic in a class it might make sense to extract an abstraction from it (if possible) and make it its own class for which you can then test the public (previously private) methods.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: