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

If the function had a descriptive name then its purpose would be even clearer, and the calling code would be more readable too.

Nothing against unit tests, but I don't think they should serve as comments (which is more or less what you suggest).



Actually, I think it's important not to think of tests necessarily as "comments," but rather as "specs." This is pretty much the thesis of Behaviour Driven Development.

If your tests define what your program _should_ do, then your tests can become (a) more understandable and (b) more valuable to new folks familiarizing themselves with your code.

It's a subtle but important (IMHO) distinction.


Nope. Unit Tests are specs that automatically verify themselves.




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

Search: