Multiple Asserts in a Unit Test
- by whatispunk
I've just finished reading Roy Osherove's "The Art of Unit Testing" and I am trying to adhere to the best practices he lays out in the book. One of those best practices is to not use multiple asserts in a test method. The reason for this rule is fairly clear to me, but it makes me wonder...
If I have a method like:
public Foo MakeFoo(int x, int y, int z)
{
Foo f = new Foo();
f.X = x;
f.Y = y;
f.Z = z;
return f;
}
Must I really write individual unit tests to assert each separate property of Foo is initialized with the supplied value? Is it really all that uncommon to use multiple asserts in a test method?
FYI: I am using MSTest.