Search code examples
.netunit-testingassert

Multiple arrangements/asserts per unit test?


A group of us (.NET developers) are talking unit testing. Not any one framework (we've hit on MSpec, NUint, MSTest, RhinoMocks, TypeMock, etc) -- we're just talking generally.

We see lots of syntax that forces a distinct unit test per scenario, but we don't see an avenue to re-using one unit test with various inputs or scenarios. Also, we don't see an avenue to multiple asserts in a given test without an early assert's failure threatening the testing of later asserts (in the same test).

Is there anything like that happening in .NET unit testing (state- or behavior-based) today?


Solution

  • look at [TestCase(params)] in NUnit allows doing the same test with different inputs.

    also, for the multiple asserts thing, look at OAPT (One assert per test) runner - which promises to take a test with muliple asserts and run each assert as its own test: http://rauchy.net/oapt/