I have a use case for unit tests that extend a base class for common class initialization and cleanup work. Using MSTest, this code looks like this:
[TestClass]
public class BaseTestClass
{
[TestInitialize]
public void BaseTestInitialize()
{
Console.WriteLine("BaseTestInitialize");
}
}
[TestClass]
public class TestingClass : BaseTestClass
{
[TestInitialize]
public void TestInitialize()
{
Console.WriteLine("TestInitialize");
}
[TestMethod]
public void TestSomething()
{
Console.WriteLine("TestSomething");
}
}
If I run this code using the test explorer in visual studio, and TMockRunner.exe, I get the following output, which I am expecting:
BaseTestInitialize
TestInitialize
TestSomething
Running the same TestSomething test from the SmartRunner plug-in or by clicking the shield and running the test, I get the following:
TestInitialize
BaseTestInitialize
TestSomething
It just looks like the SmartRunner is running the initialization methods in the wrong order. TestCleanup works as expected because it probably uses the same logic as the piece handling TestInitialize today.
I'm using TypeMock 7.3.0.0 and the associated plug-in that gets installed with that version. Has this bug been addressed in newer versions of TypeMock or is there a suitable workaround?