Should I create a new test method for each statement?

I know that this is subjective, but I would like to follow the most common practice. Do you usually create one test method for each class method and process it with several statements or do you create one test method for each statement?

For example, if I am testing a bank account method withdraw, and I want to make sure that an exception occurs if the user tries to reset the account or remove the negative amount, should I create testOverdawand testNegativeWithdrawal, or would I just combine these two statements in the method testWithdraw?

+5
source share
8 answers

: . , - , , , .

, , . , , , . , - , , : .

, , . , , - , 20 .

, , , , nUnit, MSTest , , , (nUnit , TestDriven.net). , . , .

+10

, , , .

, , .

+4

; . . , - , . , .

, , , .

+2

- . , , , , , . , , .

+2

, , . , - .

+1

.

, , , , .

, , , .

+1

testOverdraw testNegativeWithdrawal - . .

- unit test ( ).

+1

NUnit: " , . , , , . ".

http://www.nunit.org/index.php?p=assertions&r=2.4.6

. , 100% , ( ), . , , , . , .

0
source

All Articles