Skip to content

Commit c5dbb02

Browse files
committed
more improvements in chap 4 flowcharts + discussion
1 parent 43c98bd commit c5dbb02

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

chapter_philosophy_and_refactoring.asciidoc

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,7 @@ It's time for a little recap, and perhaps even some flowcharts.
786786
Forgive me, years misspent as a management consultant have ruined me.
787787
On the plus side, it will feature recursion.
788788
789-
What is the overall TDD process?
790-
789+
What is the overall TDD process?
791790
Well, one very common way to present it is using the three words
792791
_Red, Green, Refactor_. See <<red-green-refactor>>..
793792
@@ -798,37 +797,40 @@ image::images/red-green-refactor-excalidraw.png["Red, Green and Refactor as thre
798797
What if we want to drill down in a bit more detail? Here's what
799798
we've been doing, including what I call the _unit test/code cycle_:
800799
801-
We write a test. We run the test and see it fail.
802-
We write some minimal code to get it a little further.
803-
We rerun the test and repeat until it passes.
804-
Then, we look for opportunities to refactor our code,
805-
using our tests to make sure we don't break anything. See <<simple-tdd-diagram>>.
800+
* We write a test.
801+
* We run the test and see it fail.
802+
* We write some minimal code to get it a little further.
803+
* We rerun the test and repeat until it passes (the unit test / code cycle)
804+
* Then, we look for opportunities to refactor our code,
805+
using our tests to make sure we don't break anything.
806+
807+
See <<simple-tdd-diagram>>.
808+
806809
807810
[[simple-tdd-diagram]]
808-
.Overall TDD process
811+
.Overall TDD process including the unit test / code cycle
809812
image::images/tdd-process-unit-tests-only-excalidraw.png["A flowchart with boxes for tests, coding and refactoring, with yes/no labels showing when we move forwards or backwards"]
810813
811814
But how does this apply when we have functional tests _and_ unit tests?
812-
Well, you can think of the functional test as being a high-level view of the cycle,
815+
Well, you can think of the functional test as driving a higher-level version of the same cycle,
813816
where "writing the code" to get the functional tests to pass
814-
actually involves using another, smaller TDD cycle which uses unit tests.
817+
actually involves using another, smaller TDD cycle driven by unit tests.
815818
See <<double-loop-tdd-diagram>>.
816819
817-
We write a functional test and see it fail.
818-
Then, the process of "writing code" to get it to pass is a mini-TDD cycle of its own:
819-
we write one or more unit tests, and go into the unit-test/code cycle until the unit tests pass.
820-
Then, we go back to our FT to check that it gets a little further,
820+
* WWe write a functional test and see it fail.
821+
* Then, the process of "writing code" to get it to pass is a mini-TDD cycle of its own:
822+
* we write one or more unit tests, and go into the unit-test/code cycle until the unit tests pass.
823+
* Then, we go back to our FT to check that it gets a little further,
821824
and we can write a bit more of our application--using more unit tests, and so on.
822825
823-
TODO - a little more nuance here
826+
TODO - next paragraph needs work. clarification.
824827
825828
What about refactoring, in the context of functional tests?
826829
Well, that means we use the functional test to check that we've preserved the behaviour of
827830
our application, but we can change or add and remove unit tests, and use
828831
a unit test cycle to actually change the implementation.
829832
830-
The functional tests are the ultimate judge of whether your application works
831-
or not. The unit tests are a tool to help you along the way.
833+
The functional tests are the final sanity-check that your application works. The unit tests are there to help you figure out all the lower level bits you need along the way.
832834
833835
This way of looking at things is sometimes called "Double-Loop TDD". One of my
834836
eminent tech reviewers, Emily Bache, wrote http://bit.ly/1iXzoLR[a blog post]
14.4 KB
Loading

0 commit comments

Comments
 (0)