DEV Community

Discussion on: What were your problems with "real world TDD"?

Collapse
 
tisek profile image
tisek⚓

Disclaimer: I am not myself a total TDD enthousiast. I do not write large chunks of code driven by tests etc... I have my reasons for this however I do recognize some benefit to TDD and those that are good at it do write good code ...

Anyway, one part of TDD that is not the core of TDD but that seems to me like a nice way to dive in TDD (and I happen to actually do this even if I do not TDD the rest of my work), a way which prevents that awkward part of having an empty file and writing code that is obviously wrong just to comply with TDD.

Here it is: when you need to fix a bug on an existing project: do not fix the bug but write code that triggers that bugs, write that unit test and make sure it fails and only after that fix the bug.

Collapse
 
n_develop profile image
Lars Richter

Great point. It's so important to write a test for reproducing the bug, before you fix it. It's the only way to make sure, that the same bug will not get into production anymore. I have seen the same bug get into production more than once.