Plug data into your NUnit tests

written by tobinharris on May 24th, 2008 @ 07:13 PM

Today I found a cool feature in NUnit 2.5 Alpha 2 that I've been REALLY wanting. Basically, I wanted to be able to run tests multiple times, but with different data each time. This is now possible using the DataSource attribute.

In the case of Squilbo (a database query tool), each test is run once for each database engine the product supports. This is great, I only write the tests once and then run them against each database engine to make sure the features work universally. When I add support for Oracle, I can change one line of code and the tests will be run 3 times.

Image of Squilbo Unit Tests



kick it on DotNetKicks.com



Comments

  • Ian Nelson on 26 May 05:03

    Have you looked at xUnit.Net (http://www.codeplex.com/xunit)? The xunitext.dll extension offers support for Data-Driven tests from various sources, including Excel and SQL Server.

  • Tobin Harris on 28 May 19:17

    Saw it in the early days, but haven’t checked it out yet, but looks very promising. Thanks for the link Ian.

Post a comment

Options:

Size

Colors