Refactor Broken Unit Tests

Here's the problem. You have written unit tests, both to help you understand your design and to find bugs. In due time, you refactor your code, which causes tests to break. The interface they communicate with has changed, so they must change to match. Are there reasonable alternatives to RefactorBrokenUnitTests??

There's a bit of detailed discussion on DeletingBrokenUnitTests.

If you always RefactorBrokenUnitTests, lots of good things happen:

Therefore, when you refactor, RefactorBrokenUnitTests.


Can you give a specific example of RefactorBrokenUnitTests? This advice needs more detail before I can get an adequate feel for what it means in practice:

See the first example in MovingBrokenUnitTests. My gut feel is that, for that case, RefactorBrokenUnitTests and MovingBrokenUnitTests really mean much the same thing. That is, in both cases you'd end up using a parser.

How often are they so similar? Not always, of course. Still, although RefactorBrokenUnitTests is strictly more general, how often does it amount to finding a pre-existing stable interface and "promoting" tests there? --BrianMarick


See MovingBrokenUnitTests, DeletingBrokenUnitTests, TwoYearItch.


EditText of this page (last edited October 29, 2000) or FindPage with title or text search