Hacker News new | ask | show | jobs
by valuearb 3130 days ago
Unit tests are a poor way to validate code behavior. 30+ years of development has taught me that validation tests within the code itself are far better.

1) They run whenever the product runs. Good logging code tells you when it fails, even on customers devices.

2) By being part of the production code, they are far easier to keep up to date as the code changes even through refactoring.

3) They don’t force you to change anything about how you code.

2 comments

Agreed. I like to test the validity of a function's input and throw an exception if it fails. It catches most regressions with a nice error message.
Not sure I understand. Can you give an example?