3 ms·
> So if your code is ascertained to work at the high level, you also know that it must be working at the lower level too In the ideal world maybe. But It's ver
by integralid 1y ago
> So if your code is ascertained to work at the high level, you also know that it must be working at the lower level too
In the ideal world maybe. But It's very hard to test edge cases of a sorting algorithm with integration test. In general my experience is that algorithms and some complex but pure functions are worth writing unit tests for. CRUD app boilerplate is not.
- MoreQARespect 1y agoIve never in my life written a test for a sorting algorithm nor, im sure, will i ever need to. The bias most developers have towards integration tests reflects the fact that even though we're often interviewed on it, it's quite rare that most developers actually have to write complex algorithms. It's one of the ironies of the profession.
- yakshaving_jgt 1y agoI write parsers all the time. Why wouldn’t you test parsers in isolation?
- simianwords 1y agoSure but not everyone is working at this level. Dogmatically writing unit tests where they don’t bring much value is something that happens all the time and needs to stop. No one actually evaluates whether unit tests are needed. Unit tests at least in my experience, are needed sparingly - in specific places that encompass slightly complicated well contained logic.
- yakshaving_jgt 1y agoI think parsing happens in more places than people might think. https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...
- simianwords 1y agoyeah and if I it pops up I might write a unit test for it. i don't wanna be forced to write it for every damn thing.
- yakshaving_jgt 1y agoWho is forcing you?
- simianwords 1y agopeople who cargo cult unit tests dogmatically by creating rules like: every class or a public method must have a unit test associated with it.