r/SoftwareEngineering • u/MacroProcessor • Sep 07 '25
How do you actually use and/or implement TDD?
I'm familiar with Test-Driven Development, mostly from school. The way we did it there, you write tests for what you expect, run them red, then code until they turn green.
I like the philosophy of TDD, and there's seemingly a lot of benefits--catches unexpected bugs, easier changes down the road, clear idea of what you have to do before a feature is "complete"--but in actuality, what I see happening (or perhaps this is my own fault, as it's what I do) is complete a feature, then write a test to match it to make sure it doesn't break in the future. I know this isn't "pure" TDD, but it does get most of the same benefit, right? I know that pure TDD would probably be better, but I don't currently have the context at my work to be able to cleanly and perfectly write the tests or modify existing tests to make the test match the feature exactly. Sometimes it's because I don't fully understand the test, sometimes it's because the feature is ambiguous and we figure it out as we go along. Do I just need to spend more time upfront understanding everything and writing/re-writing the test?
I should mention that we usually have a test plan in place before we begin coding, but we don't write the tests to fail, we write the feature first and then write the test to pass in accordance with the feature. Is this bad?
The second part is: I'm building a personal project that I plan on being fairly large, and would like to have it be well-tested, for the aforementioned benefits. When you do this, do you actually sit down and write failing tests first? Do you write all of the failing tests and then do all of the features? Or do you go test-by-test, feature-by-feature, but just write the tests first?
Overall, how should I make my workflow more test-driven?
View all comments
Show parent comment
1
u/coworker Sep 11 '25
Yes you change tests as requirements change. I'm talking about when requirements change during implementation. TDD requires you to potentially waste time writing tests for code that never gets committed. This happens more in a higher velocity environment such as a startup.
Also tests do not mean high quality code, nor do they directly correlate to less technical debt. I've worked with many a TDDer who wrote poorly designed code with 100% test coverage and still it had bugs.
The primary benefit of TDD is more forced upfront design but this is not free.