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

So many unit tests just rephrase the function you're testing -- all they check is whether or not you edited the code and test at the same time.

There are some tests that are unassailable -- like checking to see if the output of a sort function is sorted and whether it has pathological complexity. On the other hand, duplicating all the conditionals in the code as tests is bullshit. Mocks are even worse!



The reason rephrasing is valuable is that it stop people from taking out or removing needed cases. If there is a test and someone changes that logic, it forces them to at least realize someone else tested and wanted that logic. Then if you search through the code and no something is unnecessary you can change the logic and the test.


And this is where the line between testing and documentation becomes blurry: I trust a running test more than (outdated?) documentation. So 'just rephrasing' does make sense in some cases.




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

Search: