Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the [Rollback] Feature in Nunit?

Tags:

asp.net

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.

like image 873
chobo2 Avatar asked Aug 16 '09 19:08

chobo2


2 Answers

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

like image 185
tvanfosson Avatar answered Oct 04 '22 22:10

tvanfosson


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.

like image 36
Laura Huysamen Avatar answered Oct 04 '22 22:10

Laura Huysamen