Hacker News new | past | comments | ask | show | jobs | submit login

I look at it like this: what are the inputs/outputs of what I’m testing? Is it calling another library to do work, spy on that. Is making side-effects in the system, watch that. The only time I’d use internal/private methods directly in a test is when setting up to use the public methods would be tremendous (imagine configuring a database driver to fail in a certain way, for example).

Most of the time, I see private methods being tested when the library is “in the middle” of other libraries, or is not properly abstracted.




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

Search: