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

In instances where I needed to test private methods, the aim was to provide extra feedback to the failure of a higher-level public method/s that by themselves do not provide enough feedback to pinpoint the issue.

It answers the question "what failed?" on a deeper level. Something you'll need to know when the public-method test fails anyway.

It's rarely needed on proper API designs (in general such scenarios can be split into a separately-testable object which is not by itself exposed), but it's not too uncommon in my experience.

In such cases, all the solutions to test private methods pretty much suck.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: