by sagolikasoppor · 1y ago · 0 comments
TDD is just a way of doing things but it's not faster. It's testing for testings sake. Why should I write a test if I don't have a single paying customer yet? Unless its something massively important, like money or health data there is just little incentives.
TDD lets you safely forget by tying the test pass/failure directly to the code.
So, yes, you can do test-after but why?
The only reason Ive ever heard for doing it after anyway is "I just prefer it that way".
Not writing tests at all makes sense (e.g. for a spike), but if I were going to start writing tests at any point I cant see any reason not to do it with TDD.
Also the higher level you test at, the less probable that you have to change the tests when you change a piece of functionality.
I frequently do TDD with integration and end to end tests. The type of test should be dictated by the nature of the code, which TDD doesnt have an opinion on.
TDD is about following red-green-refactor.
Usually, I use test harnesses[0]. These generally start before the code, and grow, alongside.
I’ll frequently write unit tests, after the code is done. Sort of like putting solder over a tightened bolt.
But I tend to spend a lot of time and effort on testing. It’s my experience, that I always find issues. I’ve never once, written “perfect” code, out of the starting gate.
Eh. WFM. YMMV.
IRT the post topic, I believe that every job I do -even “farting around” code- needs to be done as well as possible. If I always do a good job, then it becomes habit.
When writing test actually makes it faster to code, THEN it’s worth it. You can even throw the tests away later, doesn’t matter