You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapter_27_hot_lava.asciidoc
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ Let's recap our test structure so far:
19
19
They've enabled us to build the app incrementally, to refactor with confidence,
20
20
and they've supported a fast unit-test/code cycle.
21
21
22
+
// DAVID: For me it reads weirdly to put functional tests and unit tests in speech marks, at this point of the book.
23
+
22
24
We've also spent a good bit of time on our infrastructure,
23
25
packaging up our app with Docker for ease of deployment,
24
26
and we've set up a CI pipeline to run our tests automatically on push.
@@ -43,13 +45,13 @@ outline several desiderata (desirable characteristics) for tests:
43
45
| *Deterministic*: if nothing changes, the test result shouldn’t change.
44
46
| *Fast*: tests should run quickly.
45
47
| *Writable*: tests should be cheap to write relative to the cost of the code being tested.
46
-
| *Readable*: tests should be comprehensible for reader, invoking the motivation for writing this particular test.
48
+
| *Readable*: tests should be comprehensible for readers, invoking the motivation for writing this particular test.
47
49
| *Behavioural*: tests should be sensitive to changes in the behaviour of the code under test. If the behaviour changes, the test result should change.
48
50
| *Structure-agnostic*: tests should not change their result if the structure of the code changes.
49
51
| *Automated*: tests should run without human intervention.
50
52
| *Specific*: if a test fails, the cause of the failure should be obvious.
51
53
| *Predictive*: if the tests all pass, then the code under test should be suitable for production.
52
-
| *Inspiring*: passing the tests should inspire confidence
54
+
| *Inspiring*: passing the tests should inspire confidence.
53
55
|===
54
56
55
57
We've talked about almost all of these desiderata in the book:
@@ -143,13 +145,19 @@ and your database "should" be outside of that.
143
145
Why do they say that?
144
146
Apart from the smug from should-ing us?
145
147
148
+
// DAVID I don't understand that last sentence, is there a typo?
149
+
146
150
As you can tell,
147
151
I think the argument from _definitions_ is a bit of a red herring.
148
152
But you might hear instead, "the database is hot lava!"
149
153
as Casey Kinsey put it in a memorable DjangoCon talk.
150
154
There is real feeling and real experience behind these comments.
151
155
What are people getting at?
152
156
157
+
// DAVID: "I think the argument from _definitions_ is a bit of a red herring." - I found this sentence difficult
158
+
// to understand.
159
+
// DAVID: Is it worth a sentence at this point explaining the hot lave connotations? Not
160
+
// having seen the talk, I don't exactly get the analogy -- is hot lava dangerous? Fast? Unpredictable?
153
161
154
162
==== Integration and Functional Tests Get Slower Over Time
155
163
@@ -171,6 +179,9 @@ and associated expenditure on CI.
171
179
We're now spending a lot of effort on trying to move more of our unit
172
180
tests to being "true" unit tests.
173
181
182
+
// DAVID: More like 12 minutes now!
183
+
// DAVID: Will people know which Kraken you're talking about? Worth a footnote?
184
+
174
185
The problem is that these things don't scale linearly.
175
186
The more database tables you have,
176
187
the more relationships between them,
@@ -208,6 +219,7 @@ if you spend your time waiting for a slow test suite to run.
208
219
Anything longer than a few seconds and you're going to let your attention wander,
209
220
you context-switch, and the flow state is gone.
210
221
And the flow state is a fragile dream.
222
+
// DAVID: saying it's a dream implies it's not possible. Maybe just 'And the flow state is fragile.'?
211
223
Once it's gone, it takes a long time to come back.footnote:[
212
224
Some people says it takes at least 15 minutes to get back into the flow state.
213
225
In my experience, that's overblown,
@@ -247,6 +259,8 @@ that will still sound like a bit of a mystery.
247
259
So, how can we get to a position where our tests are giving us maximum feedback
248
260
on our design?
249
261
262
+
// DAVID: It might be worth engaging with the counterargument in the Test Driven Development section in John Ousterhout's
263
+
// A Philosophy of Software Design, in which he argues that TDD impairs design?
250
264
251
265
252
266
=== The Ideal of the Test Pyramid
@@ -422,6 +436,9 @@ call this approach "Ports and Adapters" (see <<ports-and-adapters>>).
422
436
.Ports and Adapters (diagram by Nat Pryce)
423
437
image::images/twp2_2601.png["Illustration of ports and adapaters architecture, with isolated core and integration points"]
424
438
439
+
// DAVID: I don't think this diagram is self-explanatory. Nice to break text up with a picture, but
440
+
// maybe this particular one doesn't add much.
441
+
425
442
This pattern, or variations on it, are known as
426
443
"Hexagonal Architecture" (by Alistair Cockburn),
427
444
"Clean Architecture" (by Robert C. Martin, aka Uncle Bob),
@@ -569,6 +586,8 @@ Inverting the Pyramid::
569
586
for what to do with a project like ours would end up,
570
587
with too many slow tests and not enough fast ones.
0 commit comments