Are multiple asserts bad in a unit test? Even if chaining?
- by Michael Haren
Is there anything wrong with checking so many things in this unit test?:
ActualModel = ActualResult.AssertViewRendered() // check 1
.ForView("Index") // check 2
.WithViewData<List<Page>>(); // check 3
CollectionAssert.AreEqual(Expected, ActualModel); // check 4
The primary goals of this test are to verify the right view is returned (check 2) and it contains the right data (check 4).
Would I gain anything by splitting this into multiple tests? I'm all about doing things right, but I'm not going to split things up if it doesn't have practical value.
I'm pretty new to unit testing, so be gentle.