Hello, my name is Dmitry Karlovsky. And you're on Core Dump , where we take different topics from computer science and deconstruct them piece by piece. We'll start with test-driven development.
Test Driven Development
The essence of this approach is to ritualize the development process. That is, in the uncritical unconditional execution of certain simple actions.
This ritual will make your code beautiful and reliable. It will be easy and simple to maintain. And development will be simple and fast. This is, at any rate, strongly convinced by the preachers of TDD.
Video recording of this analysis .
The essence of TDD
In short, the ritual cycle consists of 3 steps: first, a red test is written; then the code is written or corrected so that the test turns green; and finally the code is refactored to keep the tests greenish.
And then the question immediately arises a question of a million ...
What to do when the test is initially green?
Answer options ...
- Break the code
- Delete test
- It's impossible
If you break your code, your tests will naturally turn red. And after we roll back the change, the tests will turn green again.
You can delete the test. After all, if there is no test, then there is no problem with its original color.
, : TDD . - , . , .
, , : — . , , TDD.
, . , : " ?". . — . , " ", . - , ?
, TDD , - , , . , . .
— , , 2 . ?
. , , . TDD , , , , , -, . .
- R ⇝ G
- R ⇝ G
- R ⇝ G
- G ?
- G ?
- G ?
- G ?
- G ?
, TDD, , . , . , .
, TDD: , .
TDD
, , TDD ...
" ?". , . . . , . , , . , . , .
. , . , . , .
, , , " ?". , — , — -. , . , .
TDD . ...
TDD
TDD , . , .
...
1 | R | R | G |
2 | GR | RR | GG |
3 | GGR | RRR | GGG |
4 | GGGR | GGRR | GGGG |
5 | GGGGR | GGGGR | GGGGG |
6 | GGGGGR | RRRRRR | GGGGGG |
. , , . , , . .
, - , . TDD - .
, , . . " , ". , , .
TDD
TDD , . ..
, , , .
, , , , , . , TDD, . , Test Driven, .
, TDD - . , TDD . .
TDD?
- , " TDD", , , . TDD , . , .
- :-(
- :-(
- :-(
- , :-)
- :-)
TDD, TDD . , , . , , - . TDD. — . - . , , , .
TDD?
, , ..
..
- -
, . .
- , , - , .
. .