Are multiple asserts bad in a unit test? Even if chaining?

Posted by Michael Haren on Stack Overflow See other posts from Stack Overflow or by Michael Haren
Published on 2010-03-12T04:03:36Z Indexed on 2010/03/12 4:07 UTC
Read the original article Hit count: 178

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about mstest