693
Sounds great in theory (programming.dev)
you are viewing a single comment's thread
view the rest of the comments
[-] Vlyn@lemmy.world 171 points 1 year ago

TDD is great when you have a very narrow use case, for example an algorithm. Where you already know beforehand: If I throw A in B should come out. If I throw B in C should come out. If I throw Z in an error should be thrown. And so on.

For that it's awesome, which is mostly algorithms.

In real CRUD apps though? You have to write the actual implementation before the tests. Because in the tests you have to mock all the dependencies you used. Come up with fake test data. Mock functions from other classes you aren't currently testing and so on. You could try TDD for this, but then you probably spend ten times longer writing and re-writing tests :-/

After a while it boils down to: Small unit tests where they make sense. Then system wide integration tests for complex use-cases.

[-] ChickenLadyLovesLife@lemmy.world 26 points 1 year ago

then you probably spend ten times longer writing and re-writing tests

This is always what I've seen personally when people use TDD. And it's worse because the inevitable time crunch towards the end of the project means the developers stop maintaining the tests, which renders all of the work put into the tests up to that point useless.

[-] PeriodicallyPedantic@lemmy.ca 14 points 1 year ago

That's not a problem with unit tests, that's a problem with project management

load more comments (8 replies)
this post was submitted on 05 Aug 2023
693 points (97.9% liked)

Programmer Humor

32267 readers
15 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS