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

Like all things taught and learned by cargo-culting, unit tests have long lost the original intent.

No, a unit is not a function, or a method, or a class, or a file.

A unit is a clearly separated, non-trivial software component with a minimal and stable interface to the rest of the software system.

A unit is a good if it requires little to no mocking to test and a very small number of messages to test. It should also do something non-trivial - think small library size, not class size.

The unit should probably have a README which explains the small interface and the small number of necessary dependencies. The unit tests should largely treat the unit as a black box and be based on its promises in the README.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: