Skip to content

Commit 5cafa8b

Browse files
committed
add suggestions, thoughts
1 parent 648c309 commit 5cafa8b

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

chapter_27_hot_lava.asciidoc

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,23 @@ Functional/End-to-end tests::
271271
including all dependencies and connected external systems.
272272
They are the ultimate test that it all hangs together,
273273
and that things are "really" going to work.
274-
274+
// CSANAD: I find the expression 'things are "really" going to work' too vague.
275+
// I would rather mention User Stories here, since they very often can be turned into
276+
// functional/end-to-end tests: they are worded similarly and they both cover specific
277+
// functionalities that are valuable for a given user (edit: well, you talk
278+
// about this below, under "On Acceptance Tests").
279+
// Furthermore, I would maybe give an example for each:
280+
// "Francis starts a new list by entering a new item."
275281

276282
Integration tests::
277283
The purpose of integration tests should be to check that the code
278284
you write is integrated correctly with some "external" system or dependency.
285+
// CSANAD: this one is more tricky to find integration tests for, since we
286+
// didn't create separate 'integration tests'. Maybe an example could be
287+
// checking whether Bootstrap is loaded correctly, or perhaps the email.
288+
// Something like that would be helpful in my opinion, especially because
289+
// we promised in Chapter 05 ("Unit Tests Versus Integration Tests, and the Database")
290+
// that we would further clarify the difference.
279291

280292

281293
(True) Unit tests::
@@ -284,6 +296,10 @@ Integration tests::
284296
The ideal unit test is fully isolated
285297
from everything external to the unit under test
286298
such that changes to things outside cannot break the test.
299+
// CSANAD: I was trying to find an example of a pure unit test. I recall
300+
// we may have had some helper function at some point, for which there was
301+
// no need to use Django's TestCase but I can't find it. Maybe I'm
302+
// remembering wrong.
287303

288304
The canonical advice is that you should aim to have the majority of your tests
289305
be unit tests, with a smaller number of integration tests,
@@ -313,6 +329,10 @@ Top Layer: A minimal set of Functional/End-to-End Tests::
313329
But because they are the slowest and most brittle,
314330
we want as few of them as possible.
315331

332+
// CSANAD: I think explaining the layers after having explained the types of
333+
// tests just above it, seems a little redundant. I wonder if we should combine
334+
// them.
335+
316336

317337
[[acceptance-tests-sidebar]]
318338
.On Acceptance Tests
@@ -363,6 +383,8 @@ Ed Jung calls this https://youtu.be/CdKaZ7boiZ4[Mock Hell].
363383
This isn't to say that mocks are always bad!
364384
But just that, from experience,
365385
attempting to use them as your primary tool for decoupling
386+
// CSANAD: I think we could actually argue that by using mocks, we
387+
// accept that the code is tightly coupled with its dependencies.
366388
your tests from external dependencies is not a viable solution;
367389
it carries costs that often outweigh the benefits.
368390

@@ -376,7 +398,7 @@ NOTE: I'm glossing over the use of mocks in a "London-school"
376398
The actual solution to the problem isn't obvious from where we're standing,
377399
but it lies in rethinking the architecture of our application.
378400
In brief, if we can _decouple_ the core business logic of our application
379-
from its dependencies, then we can write true unit tests for it,
401+
from its dependencies, then we can write true, isolated unit tests for it,
380402
that do not depend on those, um, dependencies.
381403

382404
Integration tests are most necessary at the _boundaries_ of a system--at
@@ -433,6 +455,12 @@ call this approach "Ports and Adapters" (see <<ports-and-adapters>>).
433455
.Ports and Adapters (diagram by Nat Pryce)
434456
image::images/twp2_2601.png["Illustration of ports and adapaters architecture, with isolated core and integration points"]
435457

458+
// CSANAD: I haven't found the original diagram by Nat Pryce. I would recommend
459+
// maybe a making the next header "Functional Core, Imperative Shell" formatted
460+
// differently, making it more obvious that it's an explanation of the diagram.
461+
// Or, we could just add a "Legend" under the diagram, explaining what the
462+
// nodes, arrows and different shades of the layers depict.
463+
436464
This pattern, or variations on it, are known as
437465
"Hexagonal Architecture" (by Alistair Cockburn),
438466
"Clean Architecture" (by Robert C. Martin, aka Uncle Bob),
@@ -508,6 +536,7 @@ aren't the be-all and end-all.
508536
image::images/frog-in-a-pan-placeholder.png["An illustration of a frog being slowly boiled in a pan"]
509537

510538
* TODO: update image
539+
// CSANAD: I like this placeholder :D
511540

512541
For small to medium-sized applications, as we've seen, the Django test runner
513542
and the integration tests it encourages us to write are just fine.

0 commit comments

Comments
 (0)