News for hackers. Stuff that matters.
Re:Unit Testing is Overrated (2020) by pydry on Thursday April 07, 2022 @06:44AM (#30942838)
It pains me when I see developers assiduously write unit tests for every line of their code and every single bug in the code ends up encoded in those unit tests so that they fail when the bug is fixed.

Integration tests need to be the default and people need to learn when to use one or the other.

Re:Unit Testing is Overrated (2020) by tjpnz on Thursday April 07, 2022 @07:16AM (#30943014)
Are these bugs in the sense that the code's plain wrong or that the developer misunderstood the spec? Good unit tests (when written alongside the code they're testing) should go a long way towards preventing the former.
Re:Unit Testing is Overrated (2020) by pydry on Thursday April 07, 2022 @09:37AM (#30944258)
The latter. Also misunderstandings about APIs. IME these combined are usually something like 70% of all bugs so the ROI on unit tests is not particularly high.

I find integration tests paired with BDD do a good job of catching "code plain wrong" bugs as well as misused APIs and misunderstood specs. They're harder to build and run slower but the ROI is still higher.

Re:Unit Testing is Overrated (2020) by UK-AL on Thursday April 07, 2022 @07:18AM (#30943023)
Because that seems like they're doing things backwards...

You should know what result you want before you even start writing the code.

Re:Unit Testing is Overrated (2020) by pydry on Thursday April 07, 2022 @07:26AM (#30943091)
>You should know what result you want before you even start writing the code.

In theory, but IME about 50% of bugs end up being specification bugs at the high level anyway.

Once you drill down and start writing unit tests on lower levels to imitate higher level APIs that % only goes up.