@@ -884,13 +884,15 @@ Don't forget the "Refactor" in "Red, Green, Refactor"::
884
884
((("Red/Green/Refactor")))
885
885
886
886
Don't refactor against failing tests::
887
- * In general: refactoring against failing tests can easily introduce new
888
- issues and make it a lot more difficult to spot them.
889
- * Refactoring against failing FTs, however, is often necessary and excusable
890
- because FTs address user stories, focusing on the "what" in development.
891
- They cover extensive parts of the application, and aren't tightly tied to
892
- the code. Unlike unit tests, which focus on the "how" to implement the
893
- functionality, guiding the implementation more directly.
887
+ * The general rule is that you shouldn't mix refactoring and behaviour
888
+ change. Having green tests is our best guarantee that we aren't changing
889
+ behaviour. If you start refactoring against failing tests, it becomes much
890
+ harder to spot when you're accidentally introducing a regression.
891
+ * This applies strongly to unit tests. With functional tests, because we
892
+ often develop against red FTs anyway, it's sometimes more tempting to
893
+ refactor against failing tests. My suggestion is to avoid that temptation
894
+ and use an early return, so that it's 100% clear if, during a refactory,
895
+ you accidentally introduce a regression that's picked up in your FTs.
894
896
* You can occasionally put a skip on a test which is testing something you
895
897
haven't written yet.
896
898
* More commonly, make a note of the refactor you want to do, finish what
0 commit comments