How can I run NUnit tests in parallel?

Viewed 60586

I've got a large acceptance test (~10 seconds per test) test suite written using NUnit. I would like to make use of the fact that my machines are all multiple core boxes. Ideally, I'd be able to have one test running per core, independently of other tests.

There is PNUnit, but it's designed for testing for threading synchronization issues and things like that, and I didn't see an obvious way to accomplish this.

Is there a switch/tool/option I can use to run the tests in parallel?

13 Answers

As an alternative to adding the Parallelizable attribute to every test class:

Add this into the test project AssemblyInfo.cs class for nunit3 or greater:

// Make all tests in the test assembly run in parallel
[assembly: Parallelizable(ParallelScope.Fixtures)]

To achieve level of parallelism ensure to do these two:

1)Nunit Explorer - Settings - Run tests in parallel

2)LevelOfParallelism

This is an assembly-level attribute used to specify the level of parallelism, that is, the maximum number of worker threads executing tests in the assembly.

In Assemblyinfo.cs, set

[assembly:LevelOfParallelism(N)] => here N is number

Related