title: "Shared" test setup (ClassInitialize) in MSTest using base class inheritance
body: <p>Having problems executing my test suite (using ReSharper), it looks as though static result set clash when multiple test classes are run together, not a problem for a separate run. the structure, in essence is similar to this:</p>
  
  <pre><code>public class TestBase
  {
      protected static Sum Target;
  
      protected static void Init(int a, int b)
      {
          Target = new Sum(a, b);
      }
  }
  
  [TestClass]
  public class TestClass1 : TestBase
  {
      [ClassInitialize]
      public static void Setup(TestContext context) { Init(1, 2); }
  
      [TestMethod]
      public void Test()
      {
          Assert.AreEqual(3, Target.Result);
      }      
      ... // plus around 20 tests
  }
  
  [TestClass]
  public class TestClass2 : TestBase
  {
      [ClassInitialize]
      public static void Setup(TestContext context) { Init(3, 4); }
  
      [TestMethod]
      public void Test()
      {
          Assert.AreEqual(7, Target.Result);  // failed. Expected:&lt;7&gt;. Actual:&lt;3&gt;
      }
      ... // plus around 20 tests
  }
  </code></pre>
  
  <p>I understand this is due to my poor usage of static variables and would appreciator any good suggestions on how to structure this better, assuming I have around 20 unit tests in each Test Class and test setup is way more complicated than the above illustration. </p>