Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

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.

like image 800
A-K Avatar asked Jun 21 '11 14:06

A-K


People also ask

What order does NUnit run tests?

Ordered tests are started in ascending order of the order argument. Among tests with the same order value or without the attribute, execution order is indeterminate. Tests do not wait for prior tests to finish. If multiple threads are in use, a test may be started while some earlier tests are still being run.

Does NUnit support parallel execution?

Parallel execution is supported by the NUnit framework on desktop . NET runtimes and . NET Standard 2.0.


1 Answers

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...

like image 187
Aasmund Eldhuset Avatar answered Oct 10 '22 18:10

Aasmund Eldhuset