title: Is there a non-static ClassInitialize alternative in MSTest?
body: <p>I'm using Visual Studio 2012 test framework (I guess that's MSTest). I have some code that I need to run <strong>once and only once</strong> before the various testmethods run. ClassInitialize seemed perfect until I learned that it must be static. </p>
  
  <p>First, I have an instance variable for ChromeDriver:</p>
  
  <pre><code>private ChromeDriver driver;
  </code></pre>
  
  <p>I think I need to have something like this, but nonstatic:</p>
  
  <pre><code>[ClassInitialize]
  public static void Initialize() {
      ChromeOptions options = new ChromeOptions();
      options.AddArgument("test-type");
      options.AddArgument("start-maximized");
      options.LeaveBrowserRunning = true;
      driver = new ChromeDriver(@"C:\MyStuff", options);
      driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));
  }
  </code></pre>
  
  <p>The above does not compile because class instances are being newed up inside this static method. But I'm forced to make it static, or runtime errors result saying "this has to be a static method" and "wrong signature", etc.</p>
  
  <p>If I spin up my ChromeDriver (declared as a class variable) either in the class constructor or in a TestInitialize method, everything works fine BUT <strong>a new browser window opens for each and every test</strong>. So when I have 50 test methods I'm going to have 50 instances of Chrome opened, and that's bad.</p>
  
  <p>I just want to reuse my <code>driver</code> instance for every test and not have to spin up a new one each time, which opens a new browser.</p>
  
  <p>How can this be done?</p>