views:

961

answers:

1

I have some code that uses the shared gateway pattern to implement an inversion of control container. I have several hundred NUnit unit tests that exercises the code that uses this IOC. They all work (on my machine!) but I am concerned that these tests might fail under load. I seem to remember that NUnit (and MSTest) attempts to run tests in parallel on multiple threads (which would definitely trigger race conditions on the static/shared gateway) but I cannot find any documentation that says what actually happens. My experience is that NUnit seems to be running the tests sequencially. My question is, does NUnit (or MSTest) ever run unit tests in parallel? If so, under what conditions? And, can I turn this off via some sort of configuration option?

+2  A: 

MsTest:
So according to David Williamson, from Microsoft Visual Studio Team System, on this post in the MSDN forums:

Tests absolutely do NOT run in parallel when run in VS or via mstest.exe. If they are run in a Load Test through VS then that is a different story. Basic execution, however, is always serial.

Also, tests run using MsTest are each run using a different thread in order to ensure that you have a clean slate for each test. There is no way to disable this behavior.

NUnit:
NUnit runs all tests on the same thread.

Josh