chobo2
chobo2

Reputation: 85845

Where is the [Rollback] Feature in Nunit?

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.

Upvotes: 6

Views: 2790

Answers (3)

Laura Huysamen
Laura Huysamen

Reputation: 398

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.

Upvotes: 2

Jason Irwin
Jason Irwin

Reputation: 2045

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

Upvotes: 1

tvanfosson
tvanfosson

Reputation: 532605

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

Upvotes: 4

Related Questions