Skip to content

Commit bfeb907

Browse files
authored
Merge pull request #247 from seddonym/seddonym-chap-12
Review Chapter 12
2 parents d36b0c3 + 78adfec commit bfeb907

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

chapter_12_organising_test_files.asciidoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def test_cannot_add_empty_list_items(self):
6363
----
6464
====
6565

66+
// DAVID: I think we should spell out that you want us to add this to the test file. Also,
67+
// where? As a method of NewVisitorTestCase?
68+
6669
That's all very well, but before we go any further--our
6770
functional tests file is beginning to get a little crowded.
6871
Let's split it out into several files, in which each has a single test method.
@@ -80,6 +83,8 @@ how to get there step by step.
8083
NOTE: We're back to local development now.
8184
Double check that the `TEST_SERVER` environment variable is unset in your terminal.
8285

86+
// DAVID: might be nice to remind people how they check this?
87+
8388
((("unittest module", "skip test decorator")))
8489
((("refactoring")))
8590
((("decorators", "skip test decorator")))
@@ -99,6 +104,7 @@ from unittest import skip
99104
def test_cannot_add_empty_list_items(self):
100105
----
101106
====
107+
// DAVID: The indentation here looks weird - maybe better to include the class declaration too?
102108

103109
This tells the test runner to ignore this test.
104110
You can see it works--if we rerun the tests,
@@ -172,6 +178,10 @@ https://www.oreilly.com/library/view/tidy-first/9781098151232/[Tidy First?]
172178
((("test files", "splitting FTs into many")))
173179
We start putting each test into its own class, still in the same file:
174180

181+
// DAVID: I would say this is too big a refactor all in one go.
182+
// A nicer way to do this would be to break out the base class first as one refactor, moving it into another file.
183+
// Then when we copy the files we could rename each class and delete the irrelevant methods.
184+
175185
[role="sourcecode"]
176186
.src/functional_tests/tests.py (ch11l002)
177187
====
@@ -205,6 +215,8 @@ class ItemValidationTest(FunctionalTest):
205215
----
206216
====
207217

218+
// DAVID: I also have check_for_row_in_list_table as a method - maybe I should've removed it?
219+
208220
At this point we can rerun the FTs and see they all still work:
209221

210222
----
@@ -384,6 +396,7 @@ when we're only interested in a single one.
384396
Although we need to remember to run all of them now and again, to check for regressions.
385397
Later in the book we'll set up a Continuous Integration (CI) server to run all the tests automatically,
386398
for example every time we push to master.
399+
// DAVID: "master" -> "our main branch"
387400
For now, a good prompt for running all the tests is "just before you do a commit",
388401
so let's get into that habit now:
389402

@@ -463,6 +476,8 @@ might decide that building a specific helper method is overkill at this stage,
463476
but it might be nice to have some generic way of saying, in our tests, "wait
464477
until this assertion passes". Something like this:
465478

479+
// DAVID: might be worth reminding the reader about that helper method, e.g. what it's called.
480+
466481
[role="sourcecode"]
467482
.src/functional_tests/test_list_item_validation.py (ch11l009)
468483
====
@@ -512,6 +527,8 @@ and we'll adapt it slightly:
512527
----
513528
====
514529

530+
// DAVID: I have `raise e` from that other method, not `raise`.
531+
515532
<1> We make a copy of the method, but we name it `wait_for`,
516533
and we change its argument. It is expecting to be passed a function.
517534

@@ -595,6 +612,9 @@ and that can be executed later, and multiple times:
595612

596613
Let's see our funky `wait_for` helper in action:
597614

615+
// DAVID: Might be worth explicitly telling the reader to add that code earlier - I hadn't yet,
616+
// so I have to go back and find the right snippet.
617+
598618
[subs="macros,verbatim"]
599619
----
600620
$ pass:quotes[*python src/manage.py test functional_tests.test_list_item_validation*]
@@ -862,6 +882,8 @@ Use a tests folder::
862882
* You probably want a separate test file for each tested source code
863883
file. For Django, that's typically 'test_models.py', 'test_views.py', and
864884
'test_forms.py'.
885+
// DAVID: worth mentioning that mirroring test files to real files can pave the way for automatically running tests
886+
// relevant to your changes.
865887
* Have at least a placeholder test for 'every' function and class.
866888
((("test files", "organizing and refactoring")))
867889

0 commit comments

Comments
 (0)