|
|
|
|
|
by crazygringo
261 days ago
|
|
> One of the worst pieces of advice that I ever received was that every function should be unit tested. Obviously not every function should be -- many are so obvious and straightforward that there's nothing to test -- but every function that does anything vaguely "algorithmic" should be. Unit testing is really important for catching logic errors. > Instead, write higher level tests close to the client/user facing behaviour that actually give you protection against breaking things unintentionally Yes, these are good. But they're a different kind of test. There are tests for correctness, and tests that the program runs. You need both. In fact, sometimes you even need to split up functions smaller than they otherwise would be, just so you can test an inner logic portion independently. |
|
I've had this exact same discussion with people before. The same people that say "unit tests are worthless because the implementation could change, then the test gets thrown away". Honestly, it drives me bonkers because that entire argument makes no sense to me.