In test development, do you write all possible tests first, then code?

During the test-based development process, I got used to writing the first unit test for the new part of the functionality first, and then writing the code for this function. If I have additional tests for writing to cover all the scripts, I usually write them after writing the code. Is this considered a bad form? Should I first try to write all conceivable tests for a piece of functionality before writing this code?

+3
source share
10 answers

To correctly execute TDD, you always write the test first, and then the second functionality.

, , 20 , 20 . , / , . , TDD, , /.

+12

, " ". "":

, . Interfaces. :

  • A (API )
  • Unit Test xyz,
  • (//)
  • 2 + 3 .

, . , . , , , , .

. , , , ( , ). powererd Mercurial MQ.

+6

TDD / . :

  • ,
  • .

, , .

+4

, . , , , . , " ". , , , , .

, -, , .

+2

, , , . , . , , . , , .

, , , , , ... , , .

, , , , , "TDD Video"

http://agilesoftwaredevelopment.com/videos/test-driven-development-basic-tutorial (oops, , )

+2

- . , , . , , , .

, , - , , . , , . , , .

+2

, TDD. (, , ) , , , , , re test-driving. .

TDD . , , - . , , . , .

TDD . , , , . - , , , : ", ", , , , , , .

red-green-refactor: , ( "", , ), , ( "" ), , , ( "" ). , , , . , / .

, , , . , , , , .

, , : . () .

+2

TDD , , , . .

+1

TDD, . - . ( ), , , , , , ( , ), . , .

0

1 .. , . , , , .

If you need to write a lot of tests for one unit of code (method, function, etc.), this may be a sign that you are trying to do too much on this device ... which, in turn, makes the dificult block for testing and refactoring at a later time.

0
source

Source: https://habr.com/ru/post/1720188/


All Articles