shekhar
shekhar

Reputation: 1432

Are TestMethods inside a TestClass executed in parallel?

I have a TestClass containing a member variable (the class that is being tested) that is initialized in a setup method with the [Testinitialize] attrib. Now i have multiple tests for this member in different methods marked with [TestMethod] attrib.

Each method modifies the member object slightly to test various scenarios.

My question is do the test methods inside a test class ever get executed in parallel?

If they do run in parallel (by parallel i mean in separate threads) depending on the runner - having a single object in the test class wouldn't be correct ? The state of the object could be changed in either [TestMethod] and end up in a bad state?

Upvotes: 2

Views: 123

Answers (1)

Jason Lind
Jason Lind

Reputation: 263

Apparently Visual Studio 2015 now supports parallel unit testing, I have not tried it so I honestly do not understand the implications of that.

TestInitialize is called for each Test, there is a ClassInitialize attribute that will be called once for the entire Test Class regardless of which Tests are scheduled to be executed.

Upvotes: 1

Related Questions