A few questions about unit tests

Two questions about unit tests.

  • I write unit tests for while, as a rule, they are usually test classes that I already wrote. I recently read an article article (remember the old article) that says: you have to write unit tests before you start writing your code.

    Does anyone really follow this methodology? It seems like a good idea on paper, but in practice it?

  • Do you have to write unit tests to find out how your method handles bad / malicious input? Obviously, you would like to write tests against functions that are specifically designed to handle "user" input, to see how it handles bad / malicious data, but what about functions that should never have passed this type of data? At what point do you draw the line?
+3
source share
6 answers

Test-Driven Development (TDD) 2000- . , , . . , . , , , . , . , .

, , API API. API , , , API. API (, ), , - , , .

+8

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

, , , . , . , , , " ". , , - .

, . , , ( ). , .

, . (.. ), , - ( !) . , .

+2

Test Driven Development - . , , . , , , .

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

+2

- ?

.

, ?

.

, , / ?

.

, ? ?

.

- - . , .

. .

, .

? , ? . , , - .

, , , ? . . - .

, - , ( ) ? . . , . , .

+2

. , . , , . !

, , . , , .

+1

, , № 2.

unittest " ", , "" "". , , .

0

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


All Articles