Reputation: 2085
I have a class with tests after many red-green cycles. I see that the class is to big and make different tasks.
Now i want refactor it... after refactoring i have 3 classes and still 100% coverage and all tests are still green.
But the problem is, i test the new two classes over the tests from the "old big class", should i split the tests now?? Or should i write extra tests for each class before i refactore the code in classes?
Upvotes: 0
Views: 104
Reputation: 57279
should i split the tests now??
A quick implication of "refactoring" -- your tests didn't need to change. The public API and the observable behaviors of your implementation were not changed. You've just created some new module boundaries within the implementation.
(If the changes you made forced you to modify the existing tests, then the activity you were doing was not "refactoring").
Since the public API hasn't changed, the existing tests still have value - they describe the required behaviors of your original API. So you shouldn't "split" those tests.
If the new classes that you created during refactoring are going to be lifted into the public API, then you should introduce new tests for the new public API.
Your existing tests of the original API remain untouched until you have announced that API's end of life, deprecated it, and reached the end of life deadline. At that point, you can delete the tests of the old API.
Upvotes: 2