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
0
u/EasyTelevision6741 Sep 11 '25
Let's say you write your tests after the fact. Do you not have to change them when requirements change? Or do you only write tests once you are certain requirements aren't going to change anymore? You have to change your code either way right?
I'd argue a startup is exactly the time to do TDD and make it a cultural thing out of the gate. Going fast and writing a bunch of shitty code and leaving mountains of technical debt sounds like the perfect recipe to turn a startup into a failure in the long run. Short term gains over long term sustainability.