4 ms·
Yep. There is a kind of goldilocks zone: - Company starts out, lots of change and RFCs, testing at a shallow depth (high-level tests wherever possible) helps a
by rdsubhas 8y ago
Yep. There is a kind of goldilocks zone:
- Company starts out, lots of change and RFCs, testing at a shallow depth (high-level tests wherever possible) helps a ton
- [Goldilocks zone] Company and team settles down, predictable workflow, "not changing the world" anymore, unit tests help
- Project goes into legacy, needs to be split/ merged/ refactored/ rearchitected/, again unit tests don't help. Back to shallow tests and stranglers
Only very small part of programming today is doing hardcode datascience and algorithms. Rest are all just plumbing from A to B to C. I always argued in teams to focus on higher level tests, but then, its easy to get shouted down because of "TDD". Sadly, very few people seem to focus on objective rather than process.
- murukesh_s 8y agoYea exactly, it's often painful to see when all you need is an API level test which will anyway cover all the use cases instead of the low level unit tests written for the sake of TDD.. leaner the code more maintainable it is
- humanrebar 8y ago> I always argued in teams to focus on higher level tests... In my experience, your inclinations are true, but it actually takes more discipline and buy in from leadership for it to work. If broken tests are lower priority than feature work, your test suite ends up rotting, getting ignored, then abandoned. At least with unit tests, individual contributors can maintain pockets and layers of verified-working code. I'm not arguing against any kind of test. But you do need the people handing out raises, planning sprints, scheduling deadlines, etc. to be on board for end-to-end testing to work. It also helps a lot to introduce those early in the system's life, since the team culture develops with the tests already being there.
- rimliu 8y agoI am confused, how unit tests do not help refactoring? Is not this a most often cited benefit of unit tests?
- spronkey 8y agoI think the definition of a 'unit' here is possibly causing some strife. If your product consists of somewhat reusable libraries that you compose together, and extend when needed, having strong unit tests for the low level functionality helps immensely when it comes time to refactor. You know, stuff like "when given int(2) and int(3) as arguments, add(int, int) returns int(5)". Likewise those high level API tests that ensure the system-as-a-whole is still doing approximately what it's supposed to, regardless of what mess of wires and small aliens is inside the black box are super useful for moving forward as both proof of functionality and guard against regression. It's the stuff in the middle that's icky IMO. Integration tests that are testing your glue that, especially these days with clouds, containers, microservices etc, can be quite far removed from any codebases you might maintain. I don't have a good solution for it, but I'm searchin'...