views:

309

answers:

5

Is it possible to run nunit tests in a multithreaded fashion? Is there any runner which can provide this?

Before someone jump on "unit test" concept, let me explain: These are not unit tests we are using nunit for functional / integration testing as well, and some of those tests are incredibly slow, got lots of wait state. Therefore multithreading can help them massively.

I know as a last resort I can roll my own multi-threading within the tests but that'll introduce an unrequired overhead.

A: 

You might want to have a look at the Overshore multithreaded test framework which has a ThreadManager class you could always extend slightly to add the concept of 'failed' tests.

http://weblogs.asp.net/rosherove/archive/2007/06/22/multi-threaded-unit-tests-with-osherove-threadtester.aspx

If you're only using asserts, you can count the exceptions.

Good luck

ps: why not run several nant/nunit-runner out of process?

Florian Doyon
yeah I've seen that, but that code is not any different than just running threads in your own thread pool (or am I missing something). It's not something clever such as [ThreadTest] - now that'd be cool :)Actually running multiple instances of nUnit is not a bad idea, just a little bit messy and requires quite a bit manual labour.
dr. evil
+1  A: 

Try Pnunit

hjb417
A: 

I'm working on a .NET port of the MultithreadedTC Java library. My port is called Ticking Test, and the source code is published on Google Code.

TickingTest wasn't originally intended to do what you're attempting, but it might work. It lets you write a test class with several methods marked with a TestThread attribute. Each thread can wait for a certain tick count to arrive, or assert what it thinks the current tick count should be. When all current threads are blocked, a coordinator thread advances the tick count and wakes up any threads that are waiting for the next tick count. If you're interested, check out the MultithreadedTC overview for examples. MultithreadedTC was written by some of the same people that wrote FindBugs.

I've used my port successfully on a small project. The major missing feature is that I have no way to track newly created threads during the test.

Don Kirkby
+1  A: 

here is a reference to PNUint http://www.codicesoftware.com/opdownloads2/oppnunit.aspx. We use it as a part of the environment to load test a web app with extensive ajax functionality

mfeingold