Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I ensure that I don't break the test code when I refactor it?
    text
    copied!<p>Code evolves, and as it does, it also decays if not pruned, a bit like a garden in that respect. Pruning mean refactoring to make it fulfill its evolving purpose.</p> <p>Refactoring is much safer if we have a good unit test coverage. Test-driven development forces us to write the test code first, before the production code. Hence, we can't test the implementation, because there isn't any. This makes it much easier to refactor the production code.</p> <p>The TDD cycle is something like this: write a test, test fails, write production code until the test succeeds, refactor the code.</p> <p>But from what I've seen, people refactor the production code, but not the test code. As test code decays, the production code will go stale and then everything goes downhill. Therefore, I think it is necessary to refactor test code.</p> <p>Here's the problem: How do you ensure that you don't break the test code when you refactor it?</p> <p>(I've done one approach, <a href="https://thecomsci.wordpress.com/2011/12/19/double-dabble/" rel="nofollow noreferrer">https://thecomsci.wordpress.com/2011/12/19/double-dabble/</a>, but I think there might be a better way.)</p> <p>Apparently there's a book, <a href="http://rads.stackoverflow.com/amzn/click/0131495054" rel="nofollow noreferrer">http://www.amazon.com/dp/0131495054</a>, which I haven't read yet.</p> <p>There's also a Wiki page about this, <a href="http://c2.com/cgi/wiki?RefactoringTestCode" rel="nofollow noreferrer">http://c2.com/cgi/wiki?RefactoringTestCode</a>, which doesn't have a solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload