Abhishek Sharma
Abhishek Sharma

Reputation: 81

Single thread for C# unit testing suite

Is there any way to run the C# test in single thread? I am not looking for a thread safe but for a single thread. Actually my COM component can be used in single thread only so when i run my first test it runs fine but as soon as it enters another it fails as COM component cannot be assigned to another thread"

Upvotes: 2

Views: 3308

Answers (2)

Michael Freidgeim
Michael Freidgeim

Reputation: 28463

VSTest.Console.Exe suppose to replace MSTest. It uses single thread -see How does the Visual Studio 2012 test runner apply threading?.

If you solution using .runsettings(e.g. see Configure unit tests by using a .runsettings file ) Visual Studio will run VSTest.Console.Exe.

More details about MSTest/VStest differences are in Choose and configure a test runner

Upvotes: 0

David Arno
David Arno

Reputation: 43264

MSTest doesn't support single-threaded testing. You'll therefore have to use another testing framework. Many options exist, though NUnit and XUnit would both meet your needs and both are popular.

Upvotes: 1

Related Questions