When doing Unit Testing, is there a way to tell the [TestClass()] to execute one [TestMethod()] by one? (Instead of Visual Studio to start multiple thread). This would be required for only one or two of my testing classes.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there is no way to do this in Visual Studio 2008 using the default tools.
It is possible by adding some … interesting configuration code to the TestInit method. For instance, you could have all of your test classes derive from the following base class.
All TestMethod instances are bracketed by calls to TestInit and TestCleanup methods. Using the Monitor.Enter/Exit combo you can guarantee that a given unit test method holds the lock for the duration of it’s execution. Therefore multiple threads cannot be running different tests at the same time in a single AppDomain.
There are error cases where this could lead to a deadlock in the testing process. But I think that is probably a minor concern as it’s not production code.