4 ms·
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
by jeroen 18y ago
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).
- iseff 18y agoActually, 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.
- stcredzero 18y agoNope. Unit Tests are specs that automatically verify themselves.