views:

30

answers:

2

In MSTest you can do something like:

[TestMethod]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "testdata.csv", "testdata#csv", DataAccessMethod.Sequential)]
public void TestSomething()
{
    double column1 = Convert.ToDouble(TestContext.DataRow["column1"]);
    ...
    Assert.AreEqual(...);
}

What is the equivalent code in NUnit 2.5?

+2  A: 

I would look at the parameterized tests documentation in NUnit 2.5 and see if you can do something like what you're doing there. I do not recall NUnit having a built-in CSV reading attribute to drive parameterized tests. There may be a community plug-in somewhere though.

I should also point out that if you are just looking for non-MS Unit Testing framework libraries to help you out, xUnit.net does have this functionality. Check out this blog post from Ben Hall

Dave White
Thanks - I have done some digging. No such plugin exists. Perhaps I will just make it myself. The main reason I asked for NUnit was because its the only testing framework Ive used, thats all.
rmx
Give xUnit a try if it will make your testing life easier in this regard. It is very similar to NUnit (James Newkirk developed both!) and it can readily live beside NUnit until you figure out if you want to fully switch over or not. I wouldn't suggest having both xUnit and NUnit as part of your ongoing solution because the runners are different and I don't think they have any ability to run each others tests.
Dave White
+1  A: 

I think the Nunit equivilent is to mark a method as a setup method and then load the data into a field to be used in subsequent tests.

You have to code it yourself, more or less.

wllmsaccnt