Validation of settings and prerequisites in unit tests

Does more than one statement per test have a really bad smell? I usually try to follow the “arrange, act, approve” pattern, and also approve a single for each testing guide. I believe clean, small, isolated tests are pure awesomeness. For the most part, I manage to do this. However, sometimes I find that I affirm the “preconditions” immediately after my dispensation as follows:

'arrange:
'pre-conditions:     
     Assert the arrange worked
'act:
'assert:

Am I testing too much? Does he care about things he shouldn't care about? I like to hear some opinions about this.

+5
source share
3 answers

, , , , , Arrange-Act-Assert, Arrange-Assume-Act-Assert. , , . , ; , , "" ; , .

+3

, Assert , ( , , , ).

, , , , , .

Debug.Assert ( #) , .

, , , .

-, , ( , , Debug.Assert ).

+1

I would not use "Assert" vanilla for this, but rather Assert.Inconclusive (MSTest) No. The test did not work, so you do not want to refuse a trial run.

1) Suppose I believe in JUnit and NUnit.

+1
source

All Articles