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

> But a lot of people cast “unit test” as “test for each method on a class” which is too low-level and coupled to the implementation; if you are writing those sort of UTs then in some sense you are doing gradient descent with a too-small step size. There is no appreciable gradient to move down; adding a new test for a small method doesn’t always get you closer to adding the next meaningful bit of functionality.

In my experience, the best time to do "test for each method on a class" or "test for each function in a module" is when the component in question is a low level component in the system that must be relied upon for correctness by higher level parts of the system.

Similarly, in my experience, it is often a waste of effort and time to do such thorough low level unit testing on higher level components composed of multiple lower level components. In those cases, I find it's much better to write unit tests at the highest level possible (i.e. checking `module.top_level_super_function()` inputs produce expected outputs or side effects)



> is when the component in question is a low level component in the system that must be relied upon for correctness by higher level parts of the system.

And then, property tests are more likely to be possible, and IMO should be preferred!


TTRD

test driven re-design?


TDRD


The first acronym cleverly demonstrates the redesign




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

Search: