Given this test fixture:
[TestClass]
public class MSTestThreads
{
[TestMethod]
public void Test1()
{
Trace.WriteLine(Thread.CurrentThread.ManagedThreadId);
}
[TestMethod]
public void Test2()
{
Trace.WriteLine(Thread.CurrentThread.ManagedThreadId);
}
}
Running the test with MSTest through Visual Studio or command line prints two different thread numbers (yet they are run sequentially anyway).
Is there a way to force MSTest to run them using a single thread?
I’ve fought for endless hours to make MSTest run in a single threaded mode on a large project that made heavy use of nHibernate and it’s not-thread-safe (not a problem, it’s just not)
ISession.We ended up more time writing code to support the multi-threaded nature of MSTest because – to the best of my and my teams knowledge – it is not possible to run MSTest in a single threaded mode.