If the unit test method exceeds 200 lines?

Too bad to write a very long (over 200 lines) test method? Or should I break it down into smaller methods?

+3
source share
6 answers

You should not (generally) create any 200-line method. If you can break it, do it.

What do you do in 200 lines? Unit testing should test small units of code. Are these 200 lines primarily statements? If yes, then it may be OK.

The key question is: can anyone understand what the method does, quickly or hard to lower its head?

" , , , ". ( , )

+11

200 . unit test . " " , . .

- , , , Eager Test.

, , Arrange/Act/Assert. 200 , , , , .

+4

, , , , . , , .

+2

, 200 . , , , : , , , , .

, : -)

+1

. , .

unit-tests, . , -, .

+1

- , unit test, , .

, 200 , , , .

, , . ( ), .

+1

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


All Articles