How to run NUnit test fixtures serially?

I have several suites of integration tests implemented in C#/NUNit. Each test suite is a separate class, each fixture setup creates and populates a SQL Server database from scripts. This all used to work just fine prior to Resharper 5.1.

Unfortunately, Resharper 5.1 begins to run several fixtures at the same time. This is a breaking change – they are all attempting to create and populate the same database, which obviously ends up in an mess. Is there any way I could have Resharper run my test fixtures serially?

  • Refreshing metadata on user functions t-SQL
  • TSQL Pivot Long List of Columns
  • SQL query to replace | in address field to front
  • how to get intellisense work in SQL server 2008 R2 with Visual studio sp1?
  • SQL Server 2008 can't login with newly created user
  • Alter Table Add Column and update the new Column in the same conditional IF statement
  • If not, what would you suggest to run my NUnit test fixtures serially, one fixture at a time?
    The order in which individual tests run does not matter.

  • Many-to-many relationship left and right keys flipped after Entity Framework 5 upgrade
  • Locking the record and unlocking
  • Closing SQL-connection but open connections keeps incrementing
  • How do I obtain a list of all schemas in a Sql Server database
  • How to insert data from listbox into database?
  • How to overwrite .mdf file
  • 4 Solutions collect form web for “How to run NUnit test fixtures serially?”

    I don’t know whether it is possible to prevent ReSharper from running tests in parallel; if not, the following hack might work: Create a static class with a static readonly Monitor member. Then, in [TestFixtureSetUp], call Enter() on the monitor, and call Exit() on the monitor in [TestFixtureTearDown]. That way, only one test fixture will be allowed to run at a time. Not pretty, though…

    Are you sure about this ? I just tried this out.. by putting a trace of the following form in tests in 3 diff NUnit fixtures followed by a “Run all”. Doesn’t seem to be running in parallel.

    Trace.WriteLine(DateTime.Now.ToString("hh:mm:ss.ffff") + "VC:Start");
    Trace.WriteLine(DateTime.Now.ToString("hh:mm:ss.ffff") + "VC:Done");

    Output I see is : (R# Build 5.1.1753.1)

    01:06:41.6649Done - IOC

    Unless the code being tested does its own transaction management, you can run each test inside a transaction. In that way, the different tests won’t disturb each other. Also, you don’t have to worry about cleaning up after each test, since the each test’s transaction can simply abort after the test is completed.

    In our projects, we usually let our integration tests derive from a class that looks more or less like this:

    public class TransactionalTestFixture
        private TransactionScope TxScope;
        public void TransactionalTestFixtureSetUp()
            TxScope = new TransactionScope(TransactionScopeOption.RequiresNew, 
                                           new TransactionOptions {IsolationLevel = IsolationLevel.Serializable});
        public void TransactionalTestFixtureTearDown()

    Give them alphabetical names, i.e. prefix them with a letter that signifies their running order. If you need this to happen you should be able to accept this nasty naming convention too.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.