.Net, MbUnit, RowTest, TDD

Better alternative to unit test data.

Roy Osherove created two posts about how to create test data for unit tests.  First one talks about encoding test data as part of your test xml comments and the second one is how to do the same using XtUnit custom attributes.  It’s much easier and requires less typing if you use MbUnit RowTest attribute.

        [RowTest]
        [Row("Select * from categories")]
        public void UseMbUnitRowTestAttribute(string actual)
        {
            string expected = "Select * from categories";
            Assert.AreEqual(expected, actual);
        }

Advertisements