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"
Asked
Active
Viewed 2,932 times
2
-
Which testing framework are you referring to? – David Arno Jun 08 '15 at 11:39
-
C# unit testing framework? – Abhishek Sharma Jun 08 '15 at 11:40
-
Which C# unit testing framework? – Rowland Shaw Jun 08 '15 at 11:41
-
@AbhishekSharma, which one? MSTest, NUnit, XUnit, ANOtherUnit? Each will have a different way of dealing with this situation. – David Arno Jun 08 '15 at 11:42
-
Microsoft.VisualStudio.TestTools.UnitTesting; – Abhishek Sharma Jun 08 '15 at 11:42
2 Answers
1
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.

Community
- 1
- 1

David Arno
- 42,717
- 16
- 86
- 131
0
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

Community
- 1
- 1

Michael Freidgeim
- 26,542
- 16
- 152
- 170