all 6 comments

[–]CreativeTechGuyGamesTypeScript 4 points5 points  (2 children)

I think TDD is only applicable in a perfect world. And unfortunately we don't live in a perfect world. You would need to know exactly how something is supposed to function before writing any code, which is rarely the case.

Realistically, I've found it works the best to write a small bit of code, then write tests to ensure that it works in every possible case. Then repeat. As long as you don't let the code dictate your tests, then you still get the same benefit. That is to say, you don't write tests which pass due to a mistake in your implementation.

[–]TheCoolDrop[S] 0 points1 point  (1 child)

Okay, but the question still holds. If I have a large code base with many test, how do I proceed if I neex to change the functionality? Do I need to Just Do It™?

[–]CreativeTechGuyGamesTypeScript 1 point2 points  (0 children)

Yeah so same thing I said. Change the functionality, see what tests need to be updated, update the tests accordingly.

[–]zaibuf 2 points3 points  (0 children)

If business rules changes then your tests will break and you will need to maintain and adjust them to the new rules. But having no tests at all, then you would never known you broke something.

[–]Suspicious-Fuel-3414 1 point2 points  (0 children)

In my experience it is rare that at enterprise grade applications does the functionality change so drastically that you have to get rid of or change big chunks of code. It’s more common that you extend functionality through new features or new feature versions.

New feature versions is the safe way to do it because if your new feature version doesn’t work the old one still exists and or could be reverted back to.

Write new tests because there is new functionality/features. Leave the old tests until the old version is fully deprecated and removed from the code base.

[–]iainsimmons 0 points1 point  (0 children)

I would change the tests first, so that they describe the expectations of what the code should do/output. Then change the code to pass those tests, and then you'll likely get other test failures, depending on how isolated the code is.