title: Using inheritance in MSTest
body: <p>I am setting up some MSTest based unit tests.  To make my life easier I want to use a base class that handles the generic setup and taredown all of my tests require.  My base class looks like this:</p>
  
  <pre><code>[TestClass]
  public class DBTestBase {
      public TestContext TestContext { get; set; }
  
      [ClassInitialize()]
      public static void MyClassInitialize(TestContext testContext) {
          var config = new XmlConfigurationSource("ARconfig_test.xml");
          ActiveRecordStarter.Initialize(Assembly.Load("LocalModels"), config);
      }
  
      [TestInitialize()]
      public void MyTestInitialize() {
          ActiveRecordStarter.CreateSchema();
          Before_each_test();
      }
  
      protected virtual void Before_each_test() { }
  
      [TestCleanup()]
      public void MyTestCleanup() {
          After_each_test();
      }
  
      protected virtual void After_each_test() { }
  }
  </code></pre>
  
  <p>My actual test class looks like this:</p>
  
  <pre><code>[TestClass]
  public class question_tests : DBTestBase {
  
      private void CreateInitialData() {
          var question = new Question()
                             {
                                 Name = "Test Question",
                                 Description = "This is a simple test question"
                             };
          question.Create();
      }
  
      protected override void Before_each_test() {
          base.Before_each_test();
          CreateInitialData();
      }
  
      [TestMethod]
      public void test_fetching() {
          var q = Question.FindAll();
          Assert.AreEqual("Test Question", q[0].Name, "Incorrect name.");
      }
  }
  </code></pre>
  
  <p>The TestInitialize function works as expected.  But the ClassInitialize function never runs.  It does run if I add the following to my child class:</p>
  
  <pre><code>    [ClassInitialize()]
      public static void t(TestContext testContext) {
          MyClassInitialize(testContext);
      }
  </code></pre>
  
  <p>Is it possible to get my base class initialize function to run without referencing it in my child class?</p>