I’m practicing with TDD and I’ve done the simplest possible implementation that satisfies my test. Now after second and third test I see that I could extract piece of my logic into dependency. What should I do with existing tests? SHould I leave them as they are and test this dependency indirectly? Or should I “rewrite” my tests and split them into pieces using stubs/mocks in original cases?
I’m practicing with TDD and I’ve done the simplest possible implementation that satisfies my
Share
If you can, I’d leave your original tests, since they’re operating as a regression test. i.e. do the tests still work now you’ve reworked the original code.
You can then write additional tests around the extracted functionality. It would possibly make sense to write more complex tests at this point to test the extracted functionality directly rather than throught the integration layer that you’ve identified/refactored out.