I have been researching different unit testing tools for .NET lately. Obviously, NUnit was the first I came across, but MbUnit had the RowTest attribute, which allows parameters to be added to tests. This saves a lot of code and is really a must have feature. Luckily, I found an NUnit addin for RowTest here. The latest version here is linked to NUnit 2.4.6, so I rebuilt it from source to use NUnit 2.4.7.
To install for TestDriven.NET, just create an addins folder in the %install root%\TestDriven.NET 2.0\NUnit\2.4\ and copy NUnitExtension.RowTest.AddIn.dll to the newly created folder. Then in your test project, just reference NUnitExtensino.RowTest and you are set to go.
Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | namespace TestExample { [TestFixture] public class Tests { [RowTest] [Row(-4,4)] [Row(-5,5)] [Row(-6,6)] public void TestAddEqualsZero(int x, int y) { Assert.IsTrue((x + y) == 0); } } |
0 Responses to “NUnit and RowTest”