6

I want to use the role back feature yet when I write the tag it seems to not exists.

I am using nunit 2.5.0

I just used the nunit.framework.dll

Do I need to add some other .dll in?

Also does anyone know how I actually get nunit to connect to a sql sever database in an asp.net application?

I am not sure where to put my connection string.

chobo2
  • 83,322
  • 195
  • 530
  • 832
  • See this question for an alternative http://stackoverflow.com/questions/321180/how-do-i-test-database-related-code-with-nunit – Mike Two Apr 28 '11 at 18:08

3 Answers3

4

I think you need to use XTUnit or NUnitX, not plain NUnit.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
2

Old thread, but I thought I'd share for future reference.

As far as I can tell, there isn't a native [Rollback] attribute. However, you can write your own pretty easily:

This blog post shows how to write a custom rollback attribute for NUnit, so that you can write [Test, Rollback] at the beginning of each test (or at the beginning of the TestFixture if you prefer).

It's fairly straightforward, and it uses System.Transaction.TransactionScope() to do the meat of it.

Of course, you can always just use TransactionScope() in your SetUp/TearDown to accomplish the same thing, see the accepted answer to this question.

Community
  • 1
  • 1
Laura Huysamen
  • 398
  • 3
  • 9
1

The is no such attribute in 2.5 (see here for a list of supported attributes). Read here for the DIY approach.

Jason Irwin
  • 1,985
  • 2
  • 29
  • 42