News for hackers. Stuff that matters.
Re:Extremely disillusioned with technology. Please help by _pmf_ on Tuesday May 05, 2020 @03:16AM (#23077350)
> The thing that unit tests are really good for is providing a safety net when you make changes

In all projects I have worked on, extensive unit tests were not a safety net against regressions, but a safety net against change.

Re:Extremely disillusioned with technology. Please help by tonyarkles on Tuesday May 05, 2020 @08:50AM (#23079449)
> but a safety net against change

Heh, yeah, that's fair, although I think there's some nuance in terms: accidental changes (to things that were working) is a form of regression in my mind. Depending on how the codebase is structured, changing the tests to match the new desired behaviour might be trivial or might be excruciatingly complicated. These days (mentioned elsewhere in this discussion) I'm working on more embedded stuff, and the only time I'm generally writing unit tests are for things that shouldn't change.

As an example, last year I was working on a custom LoRaWAN stack. As I was building out the various pieces, I was writing tests to verify that the output from generally-pure functions came out as expected. (This packet) + (This key) = (This encrypted packet). Those kinds of tests help a ton for catching stupid mistakes.