|
1 | 1 | [[chapter_12_organising_test_files]]
|
2 | 2 | == Splitting Our Tests into Multiple Files, and a Generic Wait Helper
|
3 | 3 |
|
4 |
| -// RITA: Reword/remove this warning since you have reviewed the chapter text in detail? |
5 |
| -.🚧 Warning, chapter update in progress |
6 |
| -******************************************************************************* |
7 |
| -This chapter is currently in the process of being rewritten for the 3e. |
8 |
| -
|
9 |
| -The code listings should all be valid, |
10 |
| -and work with Python3.12 + Django 4, |
11 |
| -but I haven't reviewed the chapter text in detail yet. |
12 |
| -
|
13 |
| -******************************************************************************* |
14 | 4 |
|
15 | 5 | Back to local development!
|
16 | 6 | The next feature we might like to implement is a little input validation.
|
@@ -894,10 +884,15 @@ Don't forget the "Refactor" in "Red, Green, Refactor"::
|
894 | 884 | ((("Red/Green/Refactor")))
|
895 | 885 |
|
896 | 886 | Don't refactor against failing tests::
|
897 |
| -// RITA: Why shouldn't you refactor against failing tests in general? A brief explanation would be nice here for clarity. |
898 |
| - * In general! |
899 |
| -// RITA: Please clarify the next line. It's somewhat ambiguous. Are you saying that you should refactor against failing tests in the FT you're currently working on? |
900 |
| - * But the FT you're currently working on doesn't count. |
| 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. |
901 | 896 | * You can occasionally put a skip on a test which is testing something you
|
902 | 897 | haven't written yet.
|
903 | 898 | * More commonly, make a note of the refactor you want to do, finish what
|
|
0 commit comments